trw.callbacks.callback_tensorboard_embedding
¶
Module Contents¶
Classes¶
This callback records the embedding to be displayed with tensorboard |
Functions¶
|
Return the images as (N, C, H, W) or None if not an image |
|
Keep only the small features (e.g., len(shape) == 1) for the embedding infos |
|
Return true if a vector like |
|
Special classification helper: add the class name (output and output_truth) as a string using the class |
Attributes¶
- trw.callbacks.callback_tensorboard_embedding.logger¶
- trw.callbacks.callback_tensorboard_embedding.get_as_image(images)¶
Return the images as (N, C, H, W) or None if not an image
TODO: smarter image detection!
- Parameters
images – the object to check
- Returns
None if not an image, or images with format (N, C, H, W)
- trw.callbacks.callback_tensorboard_embedding.keep_small_features(feature_name, feature_value)¶
Keep only the small features (e.g., len(shape) == 1) for the embedding infos
- Returns
if True, keep the feature else discard it
- trw.callbacks.callback_tensorboard_embedding.is_batch_vector(value, batch_size)¶
Return true if a vector like :param value: the value to test :param batch_size: the expected size of the batch
- trw.callbacks.callback_tensorboard_embedding.add_classification_strings_from_output(dataset_name, split_name, output, datasets_infos, prefix='')¶
Special classification helper: add the class name (output and output_truth) as a string using the class mapping contained in datasets_infos
- Parameters
dataset_name – the dataset name
split_name – the split name
output – the output
datasets_infos – should contain the mapping
prefix – the output and output_truth will be prefixed with prefix
- Returns
the additional strings in a dictionary
- class trw.callbacks.callback_tensorboard_embedding.CallbackTensorboardEmbedding(embedding_name, dataset_name=None, split_name=None, image_name=None, maximum_samples=2000, keep_features_fn=keep_small_features)¶
Bases:
trw.callbacks.callback_tensorboard.CallbackTensorboardBased
This callback records the embedding to be displayed with tensorboard
Note: we must recalculate the embedding as we need to associate a specific input (i.e., we can’t store everything in memory so we need to collect what we need batch by batch)
- first_time(self, datasets, options)¶
- __call__(self, options, history, model, losses, outputs, datasets, datasets_infos, callbacks_per_batch, **kwargs)¶