New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading weights for part of the network #1873
Comments
@tboquet Thanks for your reply, I think I don't have trouble adding weights to layers. The thing is, I'm now using a sequential model, say the last convolutional layer is: |
According to PR #1796, the canonical way to do this is to build both the old and the new model (you don't need to compile the old one), load weights to the old one, then use the .nodes property to manually transfer the weights to the new model. |
@KlaymenGC oops sorry I didn't understood your question, @pasky is right! |
@pasky thanks for the reply, but it seems that sequential models don't have this |
I'd try .layers for Sequential models - sorry, it's been long I've been using these. |
For a Sequential model, you can get the layers by index: weights = model.layers[5].get_weights() Or by name, if all your layers are named; layer_dict = dict([(layer.name, layer) for layer in model.layers])
weights = layer_dict['some_name'].get_weights() |
@fchollet yeah but adding weights from |
Sure it's possible. But it will require manipulating the weight array in On 2 March 2016 at 14:03, GC notifications@github.com wrote:
|
@fchollet nice, thanks for your help! |
@fchollet Is it possible instead to add an extra channel to the weights? |
hi @KlaymenGC, all , could you share your complete code how to combine the weights? Thanks. |
Hello,
Say I have weights from a trained network and now I want to change the architecture of the network by adding 2 more filters for the last convolutional layer. For the new network, I don't want to train it from scratch again, I want to load the existing weights to the network while initializing the weights for the added 2 filters using other techniques. Is there a way to do it in Keras?
The text was updated successfully, but these errors were encountered: