Created
December 4, 2018 07:47
-
-
Save hadifar/cc10e054becba4675c74442e25b360c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Assuming the original model looks like this: | |
model = Sequential() | |
model.add(Dense(2, input_dim=3, name='dense_1')) | |
model.add(Dense(3, name='dense_2')) | |
... | |
model.save_weights(fname) | |
""" | |
# new model | |
model = Sequential() | |
model.add(Dense(2, input_dim=3, name='dense_1')) # will be loaded | |
model.add(Dense(10, name='new_dense')) # will not be loaded | |
# load weights from first model; will only affect the first layer, dense_1. | |
model.load_weights(fname, by_name=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment