copy model keras 1

copy model keras

model_copy= keras.models.clone_model(model1)
model_copy.build((None, 10)) # replace 10 with number of variables in input layer
model_copy.compile(optimizer='rmsprop', loss='categorical_crossentropy')
model_copy.set_weights(model.get_weights())

Here is what the above code is Doing:
1. Create a copy of the model
2. Build the model (since it’s a new instance)
3. Compile the model (since it’s a new instance)
4. Copy the weights from the trained model to the untrained model

Similar Posts