TensorFlow.NET
TensorFlow.NET copied to clipboard
model.save Can't save anything
I use "midel.save" without saving anything. How can I save and load the trained model? The following is my code, who can help me, thank you very much
public void Run() { //1、创建模型 Tensorflow.Keras.Engine.Model model = BuildModel(); model.compile(loss: keras.losses.MeanSquaredError(), optimizer: keras.optimizers.SGD(0.02f), metrics: new[] { "mae" }); model.summary();
//2、训练模型
(NDArray train_x, NDArray train_y) = PrepareData(1000);
model.fit(train_x, train_y, batch_size: 64, epochs: 100);
model.save("D:/desktop/model/my_model.h5");
//3、应用模型(消费)
test(model);
}
只能保存权重
model.save_weights("your_model_path_file.h5")
Save issue with https://github.com/SciSharp/TensorFlow.NET/issues/932, close this one.
The model saving and loading in keras has been supported in v0.100.4. Here are the examples.