Reputation: 3636
I use Tensorflow 2.0 and the Keras sequential API to build a model. I would like to save an untrained model for baseline comparison. How do I do that? I tried to set epochs=0
and period=0
which did not work.
Here is my code:
network = NeuralNetwork() # sequential neural network
cp_callback = tf.keras.callbacks.ModelCheckpoint(filepath='./models/', save_weights_only=False, period=0)
network.fit(x_train, y_train, epochs=0, callbacks=[cp_callback])
How can I save an untrained model?
Upvotes: 1
Views: 469
Reputation: 2331
You simply have to call model.save after instanciation of your model :
network = NeuralNetwork() # sequential neural network
network.save("/your/path/.h5")
ModelCheckpoint can only be called as a callback, so during the training.
Upvotes: 2