Example #1
0
                                              video_fotograms_folder2, i + 1)
                #                pf.create_image_Variational_weights_network(myHalfBayesianMLP, video_fotograms_folder3, i+1)
                pf.create_Bayesian_analysis_charts(
                    myGeneralVBModel, X_data_tr, Y_data_tr, X_data_val,
                    Y_data_val, tr_data_loss, val_data_loss, KL_loss,
                    xgrid_real_func, ygrid_real_func, video_fotograms_folder4,
                    i + 1)

        if (save_model_per_epochs):
            myGeneralVBModel.save(folder_model +
                                  "model_parameters_epoch:%i.pk" % i)

if (create_video_training):  #
    #    pf.create_video_from_images(video_fotograms_folder,output_file = "./training_loss.avi", fps = 2)
    pf.create_video_from_images(video_fotograms_folder2,
                                output_file=folder_images +
                                "/training_weights.avi",
                                fps=2)
    #    pf.create_video_from_images(video_fotograms_folder3,output_file = "./training_Variational_weights.avi", fps = 2)

    pf.create_video_from_images(video_fotograms_folder4,
                                output_file=folder_images +
                                "/training_Variational_weights.avi",
                                fps=2)
"""
######################  SAVE MODEL ####################
"""
myGeneralVBModel.save(folder_model + "model_parameters_epoch:%i.pk" % i)
"""
#####################  STATIC PLOTS ###################### 
"""
# Set it in no training
         final_loss_val.append(myGeneralVBModel.get_loss(Xval, Yval).item())
                 
         ##### CREATE VIDEO OF TRAINING ###############
         if (create_video_training):
             if ((i+1)%Step_video == 0):
                 myGeneralVBModel.eval()
 #                pf.create_image_weights_epoch(myGeneralVBModel, video_fotograms_folder_weights, i+1)
                 pf.create_Bayesian_analysis_charts(myGeneralVBModel,
                                                     X_data_tr, Y_data_tr, X_data_val, Y_data_val,
                                                     tr_data_loss, val_data_loss, KL_loss,final_loss_tr,final_loss_val,
                                                     xgrid_real_func, ygrid_real_func,
                                                     video_fotograms_folder_training, i+1)
                
                 
 if(create_video_training):  #
     pf.create_video_from_images(video_fotograms_folder_weights,output_file =folder_images +  "/training_weights.avi", fps = 2)
     pf.create_video_from_images(video_fotograms_folder_training,output_file = folder_images + "/training_Variational_weights.avi", fps = 2)
     
 """
 ######################  SAVE MODEL ####################
 """
 myGeneralVBModel.save(folder_model + "model_parameters_epoch:%i.pk"%i)
 
 """
 #####################  STATIC PLOTS ###################### 
 """
 # Set it in no training
 myGeneralVBModel.eval()
 
 if (plot_predictions):
     ####### PLOT THE LEARNT FUNCTION ############
Example #3
0
                x_grid = np.linspace(np.min([X_data_tr]) -1, np.max([X_data_val]) +1, 100)
                y_grid =  myBasicMLP.predict(torch.tensor(x_grid.reshape(-1,1),device=cf_a.device, dtype=cf_a.dtype)).detach().numpy()
            
                pf.create_image_training_epoch(X_data_tr, Y_data_tr, X_data_val, Y_data_val,
                                        tr_loss, val_loss, x_grid, y_grid, cf_a,
                                        video_fotograms_folder, i)
                pf.create_image_weights_epoch(myBasicMLP, video_fotograms_folder2, i)
                
        myBasicMLP.train()
        
    ## Convert MSE to RMSE
    tr_loss = np.sqrt(tr_loss)
    val_loss = np.sqrt(val_loss)
        
if(create_video_training):  #
    pf.create_video_from_images(video_fotograms_folder,output_file = "./training_loss.avi", fps = 2)
    pf.create_video_from_images(video_fotograms_folder2,output_file = "./training_weights.avi", fps = 2)

"""
######################  SAVE MODEL ####################
"""
myBasicMLP.save(folder_model + "model_parameters_epoch:%i.pk"%i)

"""
#####################  STATIC PLOTS ###################### 
"""
# Set it in no training
myBasicMLP.eval()

if (plot_predictions):
    ####### PLOT THE LEARNT FUNCTION ############
Example #4
0
                pf.create_image_training_epoch(X_data_tr, Y_data_tr,
                                               X_data_val, Y_data_val, tr_loss,
                                               val_loss, x_grid, y_grid, cf_a,
                                               video_fotograms_folder, i)
                pf.create_image_weights_epoch(myBasicMLP,
                                              video_fotograms_folder2, i)

        myBasicMLP.train()

    ## Convert MSE to RMSE
    tr_loss = np.sqrt(tr_loss)
    val_loss = np.sqrt(val_loss)

if (create_video_training):  #
    pf.create_video_from_images(video_fotograms_folder,
                                output_file="./training_loss.avi",
                                fps=2)
    pf.create_video_from_images(video_fotograms_folder2,
                                output_file="./training_weights.avi",
                                fps=2)
"""
######################  SAVE MODEL ####################
"""
myBasicMLP.save(folder_model + "model_parameters_epoch:%i.pk" % i)
"""
#####################  STATIC PLOTS ###################### 
"""
# Set it in no training
myBasicMLP.eval()

if (plot_predictions):
Example #5
0
                     legend=10,
                     xticks=10,
                     yticks=10)

    image_name = "reconstrunction"
    gl.savefig(folder_images + image_name, dpi=100, sizeInches=[20, 7])
    """
    ######################  SAVE MODEL ####################
    """
    myVAE.save(folder_model + "model_parameters_epoch:%i.pk" % i)
    """
    #####################  STATIC PLOTS ###################### 
    """
    if (create_video_training):  #
        pf.create_video_from_images(video_fotograms_folder_training,
                                    output_file=folder_images +
                                    "/training_weights.avi",
                                    fps=2)

if (0):
    gl.init_figure()
    ax1 = gl.subplot2grid((2, 1), (0, 0), rowspan=1, colspan=1)
    ax2 = gl.subplot2grid((2, 1), (1, 0), rowspan=1, colspan=1, sharex=ax1)

    title = "Bar Chart. " + str(symbols[0]) + "(" + ul.period_dic[1440] + ")"

    alpha = 0.9
    cumulated_samples = 0

    for i in range(5):  # (len(days_keys)):

        samples_index = day_dict[days_keys[i]]