0

I am writing a neural network to train incrementally (not online). Here is a snippet of the code


output = create_model()
model = Model(inputs=values, outputs=output)
if start_epoch > 1:
    weights_list = load_model_from_pickle()
    model.set_weights(weights_list)

model.compile(loss='binary_crossentropy', optimizer='adam')
model.fit(data , label, epochs=1, verbose=1, batch_size=1024, shuffle=False)

In essence, I want to load previously trained weights and train for a few more epochs. I read some SO reply that calling compile changes the weights? Is there any other way to do it? Does it make sense to set weight after calling compile? Will the answer change if I run my model in multi gpu setting?

princethewinner
  • 51
  • 1
  • 2
  • 5

1 Answers1

0

You need to compile the model ones and after training when you reload the model, you dont' require to compile it again. Read more here. Compile function defines the optimizer, loss functions and metrics you want. It does not change any weights. For more detailed information, read here.

Rishabh Sahrawat
  • 2,437
  • 1
  • 15
  • 32