Logger#
- class composer.Logger(state, destinations=None)[source]#
An interface to record training data.
The
Trainer
, instances ofCallback
, and instances ofAlgorithm
invoke the logger to record data such as the epoch, training loss, and custom metrics as provided by individual callbacks and algorithms. This class does not store any data itself; instead, it routes all data to thedestinations
. Each destination (e.g. theFileLogger
,InMemoryLogger
) is responsible for storing the data itself (e.g. writing it to a file or storing it in memory).- Parameters
state (State) โ The training state.
destinations (LoggerDestination | Sequence[LoggerDestination], optional) โ The logger destinations, to where logging data will be sent. (default:
None
)
- destinations#
A sequence of
LoggerDestination
to where logging calls will be sent.- Type
Sequence[LoggerDestination]
- has_file_upload_destination()[source]#
Determines if the logger has a destination which supports uploading files.
Needed for checking if a model can be exported via this logger.
- Returns
bool โ Whether any of the destinations support uploading files.
- log_images(images, name='Images', channels_last=False, step=None, masks=None, mask_class_labels=None, use_table=True)[source]#
Log images. Logs any tensors or arrays as images.
- Parameters
images (np.ndarray | Tensor | Sequence[np.ndarray | Tensor]) โ Dictionary mapping image(s)โ names (str) to an image of array of images.
name (str) โ The name of the image(s). (Default:
'Images'
)channels_last (bool) โ Whether the channel dimension is first or last. (Default:
False
)step (int, optional) โ The current step or batch of training at the time of logging. Defaults to None. If not specified the specific LoggerDestination implementation will choose a step (usually a running counter).
masks (dict[str, np.ndarray | Tensor | Sequence[np.ndarray | Tensor]], optional) โ A dictionary mapping the mask name (e.g. predictions or ground truth) to a sequence of masks.
mask_class_labels (dict[int, str], optional) โ Dictionary mapping label id to its name. Used for labelling each color in the mask.
use_table (bool) โ Whether to make a table of the images or not. (default:
True
). Only for use with WandB.
- upload_file(remote_file_name, file_path, *, overwrite=False)[source]#
Upload
file_path
as a file namedremote_file_name
.Both
file_path
andremote_file_name
can be specified as format strings. Seeformat_name_with_dist()
for more information.See also
Uploading Files for notes for file uploading.