trw.basic_typing

Module Contents

Classes

ModuleCreator

Base class for protocol classes. Protocol classes are defined as:

Attributes

Numeric

Generic Shape

Shape

Shape expressed as [N, C, D, H, W, ...] components

ShapeNCX

Shape expressed as [C, D, H, W, ...] components

ShapeCX

Shape expressed as [D, H, W, ...] components

ShapeX

Shape expressed as [N, D, H, W, ...] components (the component C is removed)

ShapeNX

Generic Tensor as numpy or torch

Tensor

Generic Tensor as numpy or torch. Must be shaped as [N, C, D, H, W, ...]

TensorNCX

Generic Tensor as numpy or torch. Must be shaped as [C, D, H, W, ...]

TensorCX

Generic Tensor as numpy or torch. Must be shaped as 2D array [N, X]

TensorNX

Generic Tensor with th N and C components removed

TensorX

Generic Tensor with N component only

TensorN

Torch Tensor. Must be shaped as [N, C, D, H, W, ...]

TorchTensorNCX

Torch Tensor. Must be shaped as 2D array [N, X]

TorchTensorNX

Torch Tensor with th N and C components removed

TorchTensorX

Generic Tensor with N component only

TorchTensorN

Numpy Tensor. Must be shaped as [N, C, D, H, W, ...]

NumpyTensorNCX

Numpy Tensor. Must be shaped as 2D array [N, X]

NumpyTensorNX

Numpy Tensor with th N and C components removed

NumpyTensorX

Represent a dictionary of (key, value)

Batch

Length shaped as D, H, W, ...

Length

Represent a data split, a dictionary of any value

Split

Represent a dataset which is composed of named data splits

Dataset

DatasetInfo

Represent a collection of datasets

Datasets

DatasetsInfo

HistoryStep

History

Activation

IntTupleList

IntListList

ConvKernels

ConvStrides

PoolingSizes

Stride

KernelSize

Padding

Paddings

trw.basic_typing.Numeric

Generic Shape

trw.basic_typing.Shape

Shape expressed as [N, C, D, H, W, …] components

trw.basic_typing.ShapeNCX

Shape expressed as [C, D, H, W, …] components

trw.basic_typing.ShapeCX

Shape expressed as [D, H, W, …] components

trw.basic_typing.ShapeX

Shape expressed as [N, D, H, W, …] components (the component C is removed)

trw.basic_typing.ShapeNX

Generic Tensor as numpy or torch

trw.basic_typing.Tensor

Generic Tensor as numpy or torch. Must be shaped as [N, C, D, H, W, …]

trw.basic_typing.TensorNCX

Generic Tensor as numpy or torch. Must be shaped as [C, D, H, W, …]

trw.basic_typing.TensorCX

Generic Tensor as numpy or torch. Must be shaped as 2D array [N, X]

trw.basic_typing.TensorNX

Generic Tensor with th N and C components removed

trw.basic_typing.TensorX

Generic Tensor with N component only

trw.basic_typing.TensorN

Torch Tensor. Must be shaped as [N, C, D, H, W, …]

trw.basic_typing.TorchTensorNCX

Torch Tensor. Must be shaped as 2D array [N, X]

trw.basic_typing.TorchTensorNX

Torch Tensor with th N and C components removed

trw.basic_typing.TorchTensorX

Generic Tensor with N component only

trw.basic_typing.TorchTensorN

Numpy Tensor. Must be shaped as [N, C, D, H, W, …]

trw.basic_typing.NumpyTensorNCX

Numpy Tensor. Must be shaped as 2D array [N, X]

trw.basic_typing.NumpyTensorNX

Numpy Tensor with th N and C components removed

trw.basic_typing.NumpyTensorX

Represent a dictionary of (key, value)

trw.basic_typing.Batch

Length shaped as D, H, W, …

trw.basic_typing.Length

Represent a data split, a dictionary of any value

trw.basic_typing.Split

Represent a dataset which is composed of named data splits

trw.basic_typing.Dataset
trw.basic_typing.DatasetInfo

Represent a collection of datasets

trw.basic_typing.Datasets
trw.basic_typing.DatasetsInfo
trw.basic_typing.HistoryStep
trw.basic_typing.History
trw.basic_typing.Activation
trw.basic_typing.IntTupleList
trw.basic_typing.IntListList
trw.basic_typing.ConvKernels
trw.basic_typing.ConvStrides
trw.basic_typing.PoolingSizes
trw.basic_typing.Stride
trw.basic_typing.KernelSize
trw.basic_typing.Padding
trw.basic_typing.Paddings
class trw.basic_typing.ModuleCreator

Bases: typing_extensions.Protocol

Base class for protocol classes. Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing_extensions.runtime act as simple-minded runtime protocol that checks only the presence of given attributes, ignoring their type signatures.

Protocol classes can be generic, they are defined as:

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...
__call__(self, *args, **kwargs) torch.nn.Module