mridc.core.neural_types package
Submodules
mridc.core.neural_types.axes module
- class mridc.core.neural_types.axes.AxisKind(value)[source]
Bases:
AxisKindAbstractThis Enum represents what does varying axis dimension mean. For example, does this dimension correspond to width, batch, time, etc. The “Dimension” and “Channel” kinds are the same and used to represent a general axis. “Any” axis will accept any axis kind fed to it.
- Any = 5
- Batch = 0
- Channel = 2
- Dimension = 2
- FlowGroup = 7
- Height = 4
- Sequence = 6
- Singleton = 8
- Time = 1
- Width = 3
- class mridc.core.neural_types.axes.AxisKindAbstract(value)[source]
Bases:
EnumThis is an abstract Enum to represents what does varying axis dimension mean. In practice, you will almost always use AxisKind Enum. This Enum should be inherited by your OWN Enum if you aren’t satisfied with AxisKind. Then your own Enum can be used instead of AxisKind.
- class mridc.core.neural_types.axes.AxisType(kind: AxisKindAbstract, size: Optional[int] = None, is_list=False)[source]
Bases:
objectThis class represents axis semantics and (optionally) it’s dimensionality
- Parameters
kind (what kind of axis it is? For example Batch, Height, etc.) – AxisKindAbstract
size (specify if the axis should have a fixed size. By default, it is set to None and you typically do not want to) –
Time. (set it for Batch and) – (int, optional)
is_list (whether this is a list or a tensor axis.) – (bool, default=False)
mridc.core.neural_types.comparison module
- class mridc.core.neural_types.comparison.NeuralTypeComparisonResult(value)[source]
Bases:
EnumThe result of comparing two neural type objects for compatibility. When comparing A.compare_to(B).
- CONTAINER_SIZE_MISMATCH = 5
- DIM_INCOMPATIBLE = 3
- GREATER = 2
- INCOMPATIBLE = 6
- LESS = 1
- SAME = 0
- SAME_TYPE_INCOMPATIBLE_PARAMS = 7
- TRANSPOSE_SAME = 4
- UNCHECKED = 8
mridc.core.neural_types.elements module
- class mridc.core.neural_types.elements.CategoricalValuesType[source]
Bases:
PredictionsTypeElement type to represent labels for categorical classification task
- class mridc.core.neural_types.elements.ChannelType[source]
Bases:
ElementTypeElement to represent convolutional input/output channel.
- class mridc.core.neural_types.elements.ElementType[source]
Bases:
ABCAbstract class defining semantics of the tensor elements. We are relying on Python for inheritance checking
- compare(second) NeuralTypeComparisonResult[source]
Override this method to provide a comparison between two types.
- property fields: Optional[Tuple]
This should be used to logically represent tuples/structures. For example, if you want to represent a bounding box (x, y, width, height) you can put a tuple with names (‘x’, y’, ‘w’, ‘h’) in here. Under the hood this should be converted to the last tensor dimension of fixed size = len(fields). When two types are compared their fields must match.
- property type_parameters: Dict
Override this property to parametrize your type. For example, you can specify ‘storage’ type such as float, int, bool with ‘dtype’ keyword. Another example, is if you want to represent a signal with a particular property (say, sample frequency), then you can put sample_freq->value in there. When two types are compared their type_parameters must match.”
- class mridc.core.neural_types.elements.FloatType[source]
Bases:
ElementTypeElement type representing a single float
- class mridc.core.neural_types.elements.ImageFeatureValue[source]
Bases:
ImageValueType representing an element (single value) of a (image) feature maps.
- class mridc.core.neural_types.elements.ImageValue[source]
Bases:
ElementTypeType representing an element/value of a single image channel,
- class mridc.core.neural_types.elements.Index[source]
Bases:
ElementTypeType representing an element being an index of the sample.
- class mridc.core.neural_types.elements.IntType[source]
Bases:
ElementTypeElement type representing a single integer
- class mridc.core.neural_types.elements.LabelsType[source]
Bases:
ElementTypeElement type to represent labels of something. For example, labels of a dataset.
- class mridc.core.neural_types.elements.Length[source]
Bases:
IntTypeType representing an element storing a “length” (e.g. length of a list).
- class mridc.core.neural_types.elements.LengthsType[source]
Bases:
ElementTypeElement type representing lengths of something
- class mridc.core.neural_types.elements.LogDeterminantType[source]
Bases:
ElementTypeElement for representing log determinants usually used in flow models
- class mridc.core.neural_types.elements.LogprobsType[source]
Bases:
ElementTypeElement type to represent log-probabilities. For example, outputs of log softmax layers.
- class mridc.core.neural_types.elements.LossType[source]
Bases:
ElementTypeElement type to represent outputs of Loss modules
- class mridc.core.neural_types.elements.MRISignal(freq: Optional[int] = None)[source]
Bases:
ElementTypeElement type to represent encoded representation returned by the mri model
- Parameters
freq (sampling frequency of a signal. Note that two signals will only be the same if their freq is the same.) –
- property type_parameters
Returns the type parameters of the element type.
- class mridc.core.neural_types.elements.MaskType[source]
Bases:
PredictionsTypeElement type to represent a boolean mask
- class mridc.core.neural_types.elements.NormalDistributionLogVarianceType[source]
Bases:
ElementTypeElement to represent the log variance of a normal distribution
- class mridc.core.neural_types.elements.NormalDistributionMeanType[source]
Bases:
ElementTypeElement to represent the mean of a normal distribution
- class mridc.core.neural_types.elements.NormalDistributionSamplesType[source]
Bases:
ProbabilityDistributionSamplesTypeElement to represent tensors that meant to be sampled from a valid normal distribution
- class mridc.core.neural_types.elements.NormalizedImageValue[source]
Bases:
ImageValueType representing an element/value of a single image channel normalized to <0-1> range.
- class mridc.core.neural_types.elements.PredictionsType[source]
Bases:
LabelsTypeElement type to represent some sort of predictions returned by model
- class mridc.core.neural_types.elements.ProbsType[source]
Bases:
ElementTypeElement type to represent probabilities. For example, outputs of softmax layers.
- class mridc.core.neural_types.elements.ReconstructionTarget[source]
Bases:
TargetType representing an element being target value in the reconstruction task, i.e. identifier of a desired class.
- class mridc.core.neural_types.elements.RecurrentsType[source]
Bases:
ElementTypeElement type to represent recurrent layers
- class mridc.core.neural_types.elements.RegressionValuesType[source]
Bases:
PredictionsTypeElement type to represent labels for regression task
- class mridc.core.neural_types.elements.SequenceToSequenceAlignmentType[source]
Bases:
ElementTypeClass to represent the alignment from seq-to-seq attention outputs. Generally a mapping from encoder time steps to decoder time steps.
- class mridc.core.neural_types.elements.StringLabel[source]
Bases:
StringTypeType representing a label being a string with class name (e.g. the “hamster” class in CIFAR100).
- class mridc.core.neural_types.elements.StringType[source]
Bases:
ElementTypeElement type representing a single string
- class mridc.core.neural_types.elements.Target[source]
Bases:
ElementTypeType representing an element being a target value.
- class mridc.core.neural_types.elements.VoidType[source]
Bases:
ElementTypeVoid-like type which is compatible with everything. It is a good practice to use this type only as necessary. For example, when you need template-like functionality.
- compare(second: ABCMeta) NeuralTypeComparisonResult[source]
Void type is compatible with everything.
mridc.core.neural_types.neural_type module
- exception mridc.core.neural_types.neural_type.NeuralPortNameMismatchError(input_port_name)[source]
Bases:
NeuralTypeErrorException raised when neural module is called with incorrect port names.
- exception mridc.core.neural_types.neural_type.NeuralPortNmTensorMismatchError(class_name, port_name, first_type, second_type, type_compatibility)[source]
Bases:
NeuralTypeErrorException raised when a port is fed with a NmTensor of incompatible type.
- class mridc.core.neural_types.neural_type.NeuralType(axes: Optional[Tuple] = None, elements_type: ElementType = VoidType, optional=False)[source]
Bases:
object- This is the main class which would represent neural type concept. It is used to represent the types of inputs and
outputs.
- Parameters
axes (a tuple of AxisTypes objects representing the semantics of what varying each axis means. You can use a short,) – string-based form here. For example: (‘B’, ‘C’, ‘H’, ‘W’) would correspond to an NCHW format frequently used in computer vision. (‘B’, ‘T’, ‘D’) is frequently used for signal processing and means [batch, time, dimension/channel].
elements_type (an instance of ElementType class representing the semantics of what is stored inside the tensor.) –
example (For) –
optional (By default, this is false. If set to True, it would mean that input to the port of this type can be) –
optional. –
- compare(second) NeuralTypeComparisonResult[source]
Performs neural type comparison of self with second. When you chain two modules’ inputs/outputs via __call__ method, this comparison will be called to ensure neural type compatibility.