dacapo.experiments.tasks.predictors.one_hot_predictor

Attributes

logger

Classes

OneHotPredictor

A predictor that uses one-hot encoding for classification tasks.

Module Contents

dacapo.experiments.tasks.predictors.one_hot_predictor.logger
class dacapo.experiments.tasks.predictors.one_hot_predictor.OneHotPredictor(classes: List[str])

A predictor that uses one-hot encoding for classification tasks.

classes

The list of class labels.

Type:

List[str]

__init__(self, classes

List[str]): Initializes the OneHotPredictor.

create_model(self, architecture)

Create the model for the predictor.

create_target(self, gt)

Create the target array for training.

create_weight(self, gt, target, mask, moving_class_counts=None)

Create the weight array for training.

output_array_type()

Get the output array type.

process(self, labels

np.ndarray): Process the labels array and convert it to one-hot encoding.

Notes

This is a subclass of Predictor.

classes
property embedding_dims
Get the number of embedding dimensions.
Returns:

The number of embedding dimensions.

Return type:

int

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> embedding_dims = predictor.embedding_dims
create_model(architecture)

Create the model for the predictor.

Parameters:

architecture – The architecture for the model.

Returns:

The created model.

Return type:

Model

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> model = predictor.create_model(architecture)
create_target(gt)

Create the target array for training.

Parameters:

gt – The ground truth array.

Returns:

The created target array.

Return type:

NumpyArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> target = predictor.create_target(gt)
create_weight(gt, target, mask, moving_class_counts=None)

Create the weight array for training.

Parameters:
  • gt – The ground truth array.

  • target – The target array.

  • mask – The mask array.

  • moving_class_counts – The moving class counts.

Returns:

The created weight array and None.

Return type:

Tuple[NumpyArray, None]

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_weight(gt, target, mask, moving_class_counts)
property output_array_type
Get the output array type.
Returns:

The output array type.

Return type:

ProbabilityArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> output_array_type = predictor.output_array_type
process(labels: numpy.ndarray)

Process the labels array and convert it to one-hot encoding.

Parameters:

labels (np.ndarray) – The labels array.

Returns:

The one-hot encoded array.

Return type:

np.ndarray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> one_hots = predictor.process(labels)

Notes

Assumes labels has a singleton channel dim and channel dim is first.