TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

model.save Can't save anything

Open Z-shuaishuai opened this issue 3 years ago • 2 comments
trafficstars

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);
    }

Z-shuaishuai avatar Mar 31 '22 13:03 Z-shuaishuai

只能保存权重

aiwork24 avatar Apr 10 '22 10:04 aiwork24

model.save_weights("your_model_path_file.h5")

bigbugcc avatar Apr 25 '22 02:04 bigbugcc

Save issue with https://github.com/SciSharp/TensorFlow.NET/issues/932, close this one.

Oceania2018 avatar Nov 26 '22 15:11 Oceania2018

The model saving and loading in keras has been supported in v0.100.4. Here are the examples.

SanftMonster avatar Mar 05 '23 03:03 SanftMonster