0

I have trained a denoising auotencoder with a training set df_noised_noy_norm_y in keras. I have another data set df_active and I made this autoencoder predict it's encoded representation. Now, I want to fine-tune the trained autoencoder with this data set df_active: in other words, I want to fit the trained autoencoder with this data set df_active.

Is there an easy and efficient way to acheive that in keras ?

Here is the script of the denoising autoencoder:

checkpointer = ModelCheckpoint(filepath="modelyes.h5",
                               verbose=0,
                               save_best_only=True,
                               save_weights_only=True)
tensorboard = TensorBoard(log_dir='/tmp/autoencoder',
                          histogram_freq=0,
                          write_graph=True,
                          write_images=True)
input_enc_yes = Input(shape=(input_size,))
hidden_1 = Dense(hidden_size1, activation='relu')(input_enc_yes)
hidden_11 = Dense(hidden_size2, activation='relu')(hidden_1)
code_yes = Dense(code_size, activation='relu')(hidden_11)
hidden_22 = Dense(hidden_size2, activation='relu')(code_yes)
hidden_2 = Dense(hidden_size1, activation='relu')(hidden_22)
output_enc_yes = Dense(input_size, activation='tanh')(hidden_2)
D_autoencoder_yes = Model(input_enc_yes, output_enc_yes)

D_autoencoder_yes.compile(optimizer='adam',
                         loss='mean_squared_error', 
                         metrics=['accuracy'])
history_D_yes = D_autoencoder_yes.fit(df_noised_noy_norm_y, df_noyau_norm_y,
                               epochs=200,
                                batch_size=batch_size,
                                shuffle = True,
                                validation_data=(df_noised_test_norm_y, df_test_norm_y),
                                verbose=1, 
                                callbacks=[checkpointer, tensorboard]).history
D_autoencoder_yes.save_weights("modelyes.h5")
D_autoencoder_yes.load_weights("modelyes.h5")
Mari
  • 69
  • 1
  • 8
  • What is the problem with just calling fit with the new dataset? – Dr. Snoopy Apr 08 '18 at 13:19
  • If I do so, the model will be saved in the same checkpointer or I have to precise another checkpointer ?? And what about the old weights, they stay present in "modelyes.h5" or not ?? – Mari Apr 08 '18 at 14:14
  • You didn't really answer my question. – Dr. Snoopy Apr 08 '18 at 14:16
  • I don't know if just calling fit with the new dataset can make a problem or not because I'm ne with keras and I'm trying to understand here. – Mari Apr 08 '18 at 14:26
  • No, there is no problem with calling fit again. – Dr. Snoopy Apr 08 '18 at 14:27
  • If I do so, the model will be saved in the same checkpointer or I have to precise another checkpointer ?? And what about the old weights, they stay present in "modelyes.h5" or not ?? – Mari Apr 08 '18 at 14:29

0 Answers0