Named Tensor

class namedtensor.NamedTensor(tensor, names, mask=0)[source]
assert_size(**kwargs)

Return the raw shape of the tensor

property dims

Return the dim names for the tensor

dot(names, *others)[source]

Contract dimension names with each of the other tensors

get(name, idx)[source]

Returns a namedtensor by indexing into dim name

op(*axis_ops, dim=None, _drop=None, _add=None, **kwargs)[source]

Apply ops that may change dimensions sizes

rename(dim, name)

Rename a dimension.

renorm(p, name, maxnorm)[source]

Apply torch.Tensor.renorm() over name

property shape

The ordered dict of available dimensions.

size(dim)

Return the raw shape of the tensor

split(dim, names, **dim_sizes)

Split an of existing dimension into new dimensions.

stack(dims, name)

Stack any number of existing dimensions into a single new dimension.

transpose(*dims)

Return a new DataArray object with transposed dimensions.

property values

The raw underlying tensor object.

property vshape

The raw dim size for the tensor.

Reduction Methods

These methods return a named tensor with one or more reduced dimensions

_reduction(dims, *args)

Tupled Reduction Methods

These methods return a tuple of named tensor with one or more reduced dimensions

_tuple_reduction(dims, *args)

Non-Tensor Methods

These methods return non-tensor information.

_info(*args)

Broadcast Methods

These methods apply broadcasting before operating between two tensors.

_operate(other, *args)

Named Torch

Named torch ntorch is a module that wraps the core torch operations with named variants. It contains named variants of most of the the core torch functionality.

Dictionary Builders

These methods construct a new named tensor where the sizes are specified through an ordered dict of names.

_build(ordereddict, *args)

Other Builders

These methods construct a new named tensor where the sizes are specified through an ordered dict of names.

_build(ordereddict, *args)

Basic Functions

These functions return a named tensor of the same form as the original.

_basic(*args)

Named NN

Named nn ntorch.nn is a module that wraps the core nn operations with named variants.

Basic Modules

These modules constructors are like NN and they behave identically.

Module(*args)

torch.nn.Dropout()

Update Modules

These modules constructors are like NN.

Module(*args)

They have an extra method that allows for renaming the main named dimension.

spec()

torch.nn.Linear() torch.nn.Conv1d() torch.nn.Conv2d() torch.nn.Conv3d() torch.nn.MaxPool1d() torch.nn.MaxPool2d() torch.nn.MaxPool3d() torch.nn.ConstantPad1d() torch.nn.ConstantPad2d() torch.nn.ConstantPad3d()

Augment Modules

These modules constructors are like NN.

Module(*args)

They have an extra method that allows you to name an extra appended dimension.

spec()

torch.nn.Embedding()

Loss Modules

These modules constructors are like NN losses.

Module(*args)

torch.nn.CrossEntropyLoss() torch.nn.NLLLoss()

Distributions

A wrapping of the torch distributions library to make it more clear to sample and batch the object.

Builders

These methods construct a new named distributinon where the sizes are specified through an ordered dict of names.

_build(ordereddict, *args)

torch.distributions.Gumbel torch.distributions.Categorical torch.distributions.Poisson torch.distributions.LogNormal torch.distributions.HalfNormal torch.distributions.Normal torch.distributions.Gamma torch.distributions.HalfCauchy torch.distributions.FisherSnedecor torch.distributions.Binomial torch.distributions.Exponential torch.distributions.RelaxedBernoulli torch.distributions.StudentT torch.distributions.LowRankMultivariateNormal torch.distributions.Beta torch.distributions.NegativeBinomial torch.distributions.Weibull torch.distributions.OneHotCategorical torch.distributions.RelaxedOneHotCategorical torch.distributions.Cauchy torch.distributions.Multinomial torch.distributions.Independent torch.distributions.Chi2 torch.distributions.TransformedDistribution torch.distributions.MultivariateNormal torch.distributions.Laplace torch.distributions.Bernoulli torch.distributions.Uniform torch.distributions.Dirichlet torch.distributions.Geometric torch.distributions.Pareto