How to get the weights of Keras model?
I've build a simple model of Keras 2.2 and want to get the weights of it. How can I get all weights of the model as keras tensors?
I've build a simple model of Keras 2.2 and want to get the weights of it. How can I get all weights of the model as keras tensors?
Keras has implemented some functions for getting or setting weights for every layer.
Using these functions you can write a piece of code to get all layers' weights
for layer in model.layers:
weights = layer.get_weights() # list of numpy arrays
Or you can get the weights right from the model
from keras.models import Sequential
model = Sequential()
# ...
weights = model.get_weights() # returs a numpy list of weights
Keras model also has get_weights() and set_weights(weights) functions like every layer has.
If you need more take a look at this keras doc.