标签:load dict mode amd model 添加 shape tensor simple
1.安装Python3.6,必须是3.6因为当前KerasNet的配套版本是3.6
https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe
安装时勾选将python路径添加到环境变量
2.安装tensorflow,cmd窗口输入命令pip install tensorflow
如果太慢,可以使用清华源:pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
3.安装keras,cmd窗口输入命令pip install keras -i https://pypi.tuna.tsinghua.edu.cn/simple
可以自己训练模型,也可以加载已经训练好 h5模型,加载模型的方法如下:
var model = Sequential.LoadModel("sure_model01.h5");
float[] tokens = { 0.00f, 0.00f, 1.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 1.48f, 1.00f, 0.00f, 0.00f, 0.00f, 1.60f };
NDarray x = np.array(tokens);
x = x.reshape(1, x.shape[0]);
var y = model.Predict(x);
predict[l - 1] = y[0].argmax().asscalar<int>();
标签:load dict mode amd model 添加 shape tensor simple
原文地址:https://www.cnblogs.com/sinceret/p/11914797.html