Model Constraints
Model constraints protocol.
ModelConstraints
Bases: Protocol
Protocol for model constraints on input and output tensors.
validate_input_channels(n_channels)
Whether the given channel size is compatible with the model constraints.
Parameters:
-
n_channels(int) –The number of channels in the input tensor to validate.
Raises:
-
ValueError–If the number of channels is not compatible with the model constraints.
validate_spatial_shape(shape)
Whether the given spatial shape is compatible with the model constraints.
Shape must be of length 2 (YX) or 3 (ZYX). To validate channel dimension, use
validate_input_channels or validate_target_channels instead.
Parameters:
Raises:
-
ValueError–If the spatial shape is not compatible with the model constraints.
validate_target_channels(n_channels)
Whether the given channel size is compatible with the model constraints.
Parameters:
-
n_channels(int) –The number of channels in the target tensor to validate.
Raises:
-
ValueError–If the number of channels is not compatible with the model constraints.