(this is my first question ever!) I am working in google colab. I fine tuned a Resnet50 model in keras and saved the weights. Now, later during testing, I loaded the model weights like this:
res50 = keras.applications.ResNet50(weights= None, include_top=False, input_shape=(image_size, image_size, 3))
# Create the model
model = Sequential()
model.add(res50)
model.add(Flatten())
model.add(Dense(100, activation='relu'))
model.add(Dropout(0.5))#0.75
model.add(Dense(1, activation='sigmoid'))#softmax #to Sigmoid
model.summary()
new_model = model
new_model.load_weights('/content/drive/My Drive/model_weights.hdf5')
model.compile(
optimizer=keras.optimizers.Adam(1e-4),#1e-6
loss="binary_crossentropy",
metrics=["accuracy"],
)
Notice in last block, I compiled 'model', not 'new_model'. Yet I see that 'new_model' also becomes compiled. Further, I noticed that the weights of "model" are also updated, not just 'new_model'. Basically making any change to either changes the other. Why is this happening? Is this the right way to load the weights? I have very basic understanding of programming. Please help.