orcanet.logging
Scripts for writing the logfiles.
Module Contents
Classes
For writing the summary logfile made during training. |
|
Write logfiles during training. |
Functions
|
Generate a line in nice human readable format, |
|
Generate the content of the cells for a line in the summary file. |
|
Fill nans in a list with values from another list. |
|
When a training is started for the first time, this logs all the |
|
Log filenames used for validation. |
- orcanet.logging.gen_line_str(data, widths=None, seperator=' | ', float_precision=4, minimum_cell_width=9)[source]
Generate a line in nice human readable format, consisting of multiple spaced and seperated cells.
- Parameters
- datatuple
Strings or floats of what is in each cell. It must be in the same order and have the same length as the column names.
- widthsList or None
Optional: The width of every cell. If None, will set it automatically, depending on the data. If widths is given, but what is given in data is wider than the width, the cell will expand without notice. Must have the same length as the column names.
- seperatorstr
String that seperates two adjacent cells.
- float_precisionint
Precision to which floats are rounded if they appear in data. The length of the resulting numbercan be up to 5 characters longer than this value (due to . and e-09)
- minimum_cell_widthint
Minimum width of the cells in characters.
- Returns
- linestr
The line.
- new_widthsList
The widths of the cells.
- orcanet.logging.gen_line_cells(data, widths=None, float_precision=4, minimum_cell_width=9)[source]
Generate the content of the cells for a line in the summary file.
See gen_line_str (above) for doc.
- Returns
- cellsList
- new_widthsList
- class orcanet.logging.SummaryLogger(orga, model)[source]
For writing the summary logfile made during training.
- Parameters
- orgaorcanet.core.Organizer
Contains all the configurable options in the OrcaNet scripts.
- modelks.model.Model or None
Keras model containing the metrics to plot.
- write_line(epoch_float, lr, history_train=None, history_val=None)[source]
Write a line to the summary.txt file in the trained model folder.
Will update an existing line if possible.
- Parameters
- epoch_floatfloat
The current epoch and fileno as a float.
- lrfloat/str
The current learning rate of the model.
- history_traindict
Dict containing the history of the training, averaged over files. Keys: Metric names, e.g. “loss”, “accuracy”, … Values: Value of the metric during validation as a float.
- history_valdict or None
Dict of validation losses for all the metrics, averaged over all validation files. Keys: Metric names, e.g. “loss”, “accuracy”, … Values: Value of the metric during validation as a float.
Notes
In tf 2.2, model.metrics_names is only filled after the model has been used on data, i.e. only after that point this line can be run. Otherwise, _get_column_names will throw a NameError.
- orcanet.logging.merge_arrays(base, supp, exclude=None)[source]
Fill nans in a list with values from another list.
- Parameters
- baseList
- suppList
- excludeList or int
Which indices to ignore.
- Returns
- np.array
- class orcanet.logging.BatchLogger(orga, epoch, reset_metrics=True)[source]
Write logfiles during training.
Averages the losses of the model over some number of batches, and then writes that in a line in the logfile. The Batch_float entry in the logfiles gives the absolute position of the batch in the epoch (i.e. taking all files into account). This class is intended to be used only for one epoch = one file.
- Parameters
- orgaorcanet.core.Organizer
Contains all the configurable options in the OrcaNet scripts.
- epochtuple
Epoch and file number.
- reset_metricsbool
Reset internal state of metric after eveery batch?
- on_epoch_begin(epoch, logs=None)[source]
Called at the start of an epoch.
Subclasses should override for any actions to run. This function should only be called during TRAIN mode.
- Args:
epoch: Integer, index of epoch. logs: Dict. Currently no data is passed to this argument for this method
but that may change in the future.