orcanet.history

Module Contents

Classes

HistoryHandler

For reading and plotting data from summary and train log files.

class orcanet.history.HistoryHandler(main_folder)[source]

For reading and plotting data from summary and train log files.

property summary_file[source]
property train_log_folder[source]
plot_metric(metric_name, **kwargs)[source]

Plot the training and validation history of a metric.

This will read out data from the summary file, as well as all training log files, and plot them over the epoch.

Parameters
metric_namestr

Name of the metric to be plotted over the epoch. This name is what was written in the head line of the summary.txt file, except without the train_ or val_ prefix.

kwargs

Keyword arguments for the plot_history function.

plot_lr(**kwargs)[source]

Plot the learning rate over the epochs.

Parameters
kwargs

Keyword arguments for the plot_history function.

Returns
figmatplotlib.figure.Figure

The plot.

get_metrics()[source]

Get the name of the metrics from the first line in the summary file.

This will be the actual name of the metric, i.e. “loss” and not “train_loss” or “val_loss”.

Returns
all_metricsList

A list of the metrics.

get_summary_data()[source]

Read out the summary file in the output folder.

Returns
summary_datandarray

Numpy structured array with the column names as datatypes. Its shape is the number of lines with data.

get_best_epoch_info(metric='val_loss', mini=True)[source]

Get the line in the summary file where the given metric is best, i.e. either minimal or maximal.

Parameters
metricstr

Which metric to look up.

minibool

If true, look up the minimum. Else the maximum.

Raises
ValueError

If there is no best line (e.g. no validation has been done).

get_best_epoch_fileno(metric='val_loss', mini=True)[source]

Get the epoch/fileno tuple where the given metric is smallest.

get_column_names()[source]

Get the str in the first line in each column.

Returns
tuplecolumn_names

The names in the same order as they appear in the summary.txt.

get_train_data()[source]

Read out all training logfiles in the output folder.

Read out the data from the summary.txt file, and from all training log files in the train_log folder, which is in the same directory as the summary.txt file.

Returns
summary_datanumpy.ndarray

Structured array containing the data from the summary.txt file. Its shape is the number of lines with data.

get_state()[source]

Get the state of a training.

For every line in the summary logfile, get a dict with the epoch as a float, and is_trained and is_validated bools.

Returns
state_dictsList

List of dicts.