diff --git a/mupixutils.py b/mupixutils.py index 60a3d592e263ef36adb773bd5acdaf110c1c8d12..1192292f31c13438b292d0a370aab5a4f4fd05e5 100644 --- a/mupixutils.py +++ b/mupixutils.py @@ -184,11 +184,13 @@ def train(d_model, g_model, gan_model, dataset, output_path, val_dataset = None, history[1].append(mse) history[2].append(ssim) print("Epoch", current_epoch) - print('Val> mse[%.3e], ssim[%.3e]' % (mse, ssim)) + # print('Val> mse[%.3e], ssim[%.3e]' % (mse, ssim)) + print("Val> mse[",str(mse),"], ssim[",str(ssim),"]" % (mse, ssim)) cur_patience-=1 val_loss = mse/((ssim+1)/2) # scaling ssim on 0,1 instead of -1,1 : trouble when ssim is <0 with open(output_path+"/log.txt", 'a') as file: - file.write("[Loss] Val loss at epoch %d : MSE[%.3e], SSIM[%.3e], Validation_Loss[%.3e]\n"%(current_epoch,mse,ssim,val_loss)) + # file.write("[Loss] Val loss at epoch %d : MSE[%.3e], SSIM[%.3e], Validation_Loss[%.3e]\n"%(current_epoch,mse,ssim,val_loss)) + file.write("[Loss] Val loss at epoch ",str(current_epoch)," : MSE[",str(mse),"], SSIM[",str(ssim),"], Validation_Loss[",str(val_loss),"]\n") if val_loss < best_val_loss: best_val_loss = np.copy(val_loss) g_model.save(output_path+"/networks/Generator") @@ -211,7 +213,8 @@ def train(d_model, g_model, gan_model, dataset, output_path, val_dataset = None, cur_patience=patience else : with open(output_path+"/log.txt", 'a') as file: - file.write("[Patience]: Reached at epoch %d with best validation loss :[%.3e]\n"%(current_epoch,val_loss)) + # file.write("[Patience]: Reached at epoch %d with best validation loss :[%.3e]\n"%(current_epoch,val_loss)) + file.write("[Patience]: Reached at epoch ",str(current_epoch),"with best validation loss :[",str(val_loss),"]\n") break gc.collect() @@ -232,7 +235,8 @@ def train(d_model, g_model, gan_model, dataset, output_path, val_dataset = None, # update the generator g_loss1,_ ,_ = gan_model.train_on_batch(X_realA, [y_real, X_realB]) # summarize performance - print('Step>%d, Generator loss : %.3e' % (j, g_loss1)) + # print('Step>%d, Generator loss : %.3e' % (j, g_loss1)) + print('Step>',str(j),', Generator loss : ', str(g_loss1)) # Saving the network every time it become better and when the network already did at least 500 batches. history[0].append(g_loss1) del _,g_loss1