ncalab.prediction
Classes
Stores the result of an NCA prediction, including the number of steps it took. |
Module Contents
- class ncalab.prediction.Prediction(model, steps: int, output_image: torch.Tensor, logits: torch.Tensor, head_prediction: torch.Tensor | None = None)
Stores the result of an NCA prediction, including the number of steps it took.
Sequences are typically stored by BasicNCAModel’s “record” function, and are returned as a list of Prediction objects.
Constructor is typically not called explicitly. Rather, the forward pass of BasicNCAModel (and its subclasses) is responsible for filling its attributes.
- Parameters:
model (ncalab.BasicNCAModel) – Reference to model used for prediction.
steps (int) – Number of steps taken for the prediction.
output_image (torch.Tensor) – Output image tensor.
- model
- steps
- output_image
- _output_array: numpy.ndarray | None = None
- logits
- _logits_array: numpy.ndarray | None = None
- head_prediction = None
- _head_prediction_array: numpy.ndarray | None = None
- property image_channels: torch.Tensor
Convenience property to access the image channels as a Tensor.
- Returns:
BCWH Tensor
- Return type:
torch.Tensor
Convenience property to access the hidden channels as a Tensor.
- Returns:
BCWH Tensor
- Return type:
torch.Tensor
- property output_channels: torch.Tensor
Convenience property to access the output channels as a Tensor.
- Returns:
BCWH Tensor
- Return type:
torch.Tensor
- property output_array: numpy.ndarray
Convenience property to access the whole output image in the format of a numpy array. Brings the entire tensor to CPU on demand, and only at the first call.
- Returns:
Numpy array in BCWH format
- Return type:
np.ndarray
- property image_channels_np: numpy.ndarray
Convenience property to access the output image channels in the format of a numpy array. Brings the entire tensor to CPU on demand, and only at the first call.
- Returns:
Numpy array in BCWH format
- Return type:
np.ndarray
Convenience property to access the hidden image channels in the format of a numpy array. Brings the entire tensor to CPU on demand, and only at the first call.
- Returns:
Numpy array in BCWH format
- Return type:
np.ndarray
- property output_channels_np: numpy.ndarray
Convenience property to access the image’s output channels in the format of a numpy array. Brings the entire tensor to CPU on demand, and only at the first call.
- Returns:
Numpy array in BCWH format
- Return type:
np.ndarray
- property head_prediction_array: numpy.ndarray | None
- property logits_array: numpy.ndarray