Пример #1
0
def make_parallel_statistics(test_files, title, labels_override, save_as, epoch_schedule, save_it, tag=None, style="two_in_one_line"):
    #Save and return the plot
    #Input: Either infos about what to plot, or a tag to load it automatically
    
    if tag != None:
        test_files, title, labels_override, save_as, epoch_schedule, style, ylims, AE_yticks = get_props_for_plot_parallel(tag)
        
    #Which epochs from the parallel encoder history to take:
    how_many_epochs_each_to_train = get_how_many_epochs_each_to_train(epoch_schedule)

    #Returns ( [[Test_epoch, Test_ydata, Train_epoch, Train_ydata], ...], ylabel_list, default_label_array) 
    #for every test file
    data_from_files, ylabel_list, default_label_array = make_data_from_files(test_files, dump_to_file=dump_to_file)
    
    data_autoencoder = data_from_files[0]
    data_parallel = data_from_files[1]
    
    data_parallel_test, data_parallel_train = get_last_prl_epochs(data_autoencoder, data_parallel, how_many_epochs_each_to_train)
    
    
    fig = make_plot_same_y_parallel(data_autoencoder, data_parallel_train, data_parallel_test, default_label_array, xlabel, ylabel_list, 
                     title, legend_locations, labels_override, colors, xticks, style, ylims=ylims, AE_yticks=AE_yticks)
    
    if save_as != None and save_it==True:
        os.makedirs(os.path.dirname(save_as), exist_ok=True)
        plt.savefig(save_as)
        print("Saved plot as",save_as,"\n")
    else:
        print("Plot was not saved.")
    
    return fig
Пример #2
0
def make_parser_plot(test_files, title, labels_override, save_as, 
                     legend_locations, colors, xticks, style,
                     dump_to_file, xlabel, save_it, show_it, xrange, 
                     average_train_data_bins=1):
    #Read the data in, auto means take acc when available, otherwise loss
    data_for_plots, ylabel_list, default_label_array = make_data_from_files(test_files, which_ydata="auto",
                                                                            dump_to_file=dump_to_file)
    #Create the plot
    fig = make_plot_same_y(data_for_plots, default_label_array, xlabel, ylabel_list, title, 
                    legend_locations, labels_override, colors, xticks, style=style, 
                    xrange=xrange, average_train_data_bins=average_train_data_bins)
    #Save the plot
    if save_as != None and save_it==True:
        plt.savefig(save_as)
        print("Saved plot as",save_as)
    else:
        print("Plot was not saved.")
    
    if show_it: plt.show(fig)
def make_parallel_statistics(test_files, title, labels_override, save_as, 
                             epoch_schedule, save_it, style, ylims, AE_yticks,
                             xlabel, colors, legend_locations, xticks):
    """ 
    Save and return the plot. 
    
    It will look up the encoder+dense epochs from successive training 
    belonging to every autoencoder epoch and plot them.
    
    Input: 
        Either infos about what to plot, or a tag to load it automatically.
    Returns: 
        fig (plt figure): The plot.
    """
    
    #Which epochs from the parallel encoder history to take:
    how_many_epochs_each_to_train = get_how_many_epochs_each_to_train(epoch_schedule)
    #Returns ( [[Test_epoch, Test_ydata, Train_epoch, Train_ydata], ...], ylabel_list, default_label_array) 
    #for every test file:
    data_from_files, ylabel_list, default_label_array = make_data_from_files(test_files, dump_to_file=dump_to_file)
    data_autoencoder = data_from_files[0]
    data_parallel = data_from_files[1]
    data_parallel_test, data_parallel_train = get_last_prl_epochs(
            data_autoencoder, data_parallel, how_many_epochs_each_to_train)
    fig = make_plot_same_y_parallel(data_autoencoder, data_parallel_train, 
                    data_parallel_test, default_label_array, 
                    xlabel, ylabel_list, 
                    title, legend_locations, labels_override, 
                    colors, xticks, style, ylims, AE_yticks)
    
    if save_as != None and save_it==True:
        os.makedirs(os.path.dirname(save_as), exist_ok=True)
        plt.savefig(save_as)
        print("Saved plot as",save_as,"\n")
    else:
        if save_as is None and save_it==True:
            print("Can only save a plot if a path is given!")
        print("Plot was not saved.")
    
    return fig
Пример #4
0
labels_override=["Autoencoder", "encoder training(Dropout=0.2 in dense)", "encoder training(Dropout=0.1 in dense)"]
#legend location for the labels and the test/train box
legend_locations=(1, "upper left")
#Override xtick locations; None for automatic
xticks=None
# override line colors; must be one color for every test file, otherwise automatic
colors=["blue", "orange", "green"] # = automatic
#Name of file in the results/dumped_statistics folder to save the numpy array 
#with the plot data to; None will skip saving
dump_to_file=None



#Returns ( [[Test_epoch, Test_ydata, Train_epoch, Train_ydata], ...], ylabel_list, default_label_array) 
#for every test file
data_from_files, ylabel_list, default_label_array = make_data_from_files(test_files, dump_to_file)

data_autoencoder = data_from_files[0]
data_parallel = data_from_files[1]
data_parallel_2 = data_from_files[2]


#Which epochs from the parallel encoder history to take:
how_many_epochs_each_to_train = np.array([10, ]*1+[2, ]*5+[1, ]*200)

data_parallel_test, data_parallel_train = get_last_prl_epochs(data_autoencoder, data_parallel,
                                            how_many_epochs_each_to_train)
data_parallel_test_2, data_parallel_train_2 = get_last_prl_epochs(data_autoencoder, data_parallel_2,
                                            how_many_epochs_each_to_train)