擅长:python、mysql、java
<pre><code>from keras.models import load_model
model.save('my_model.h5') # creates a HDF5 file 'my_model.h5'
del model # deletes the existing model
# returns a compiled model
# identical to the previous one
model = load_model('my_model.h5')
</code></pre>
<blockquote>
<p>You can use model.save(filepath) to save a Keras model into a single
HDF5 file which will contain:</p>
<ul>
<li>the architecture of the model, allowing to re-create the model</li>
<li>the weights of the model</li>
<li>the training configuration (loss, optimizer)</li>
<li>the state of the optimizer, allowing to resume training exactly where you left off.</li>
</ul>
<p>You can then use keras.models.load_model(filepath) to reinstantiate your model. load_model will also take care of compiling the model using the saved training configuration (unless the model was never compiled in the first place).</p>
</blockquote>
<p>Keras常见问题:<a href="https://keras.io/getting-started/faq/#how-can-i-save-a-keras-model" rel="noreferrer">How can I save a Keras model?</a></p>