View and select functions
In 0.11, we’ve included a number of different view and select functions – under the hood, these are implemented as pass through functions – i.e. functions that apply the operator to both the mask and the data.
By way of example, consider select
; this operation can be applied to both the data
and the mask of a MaskedTensor
, and the result will then be wrapped into a new MaskedTensor
.
A quick example of this:
>>> data = torch.arange(12, dtype=torch.float).reshape((3,4))
>>> mask = torch.tensor([
[True, False, False, True],
[False, True, False, False],
[True, True, True, True]])
>>> mt = masked_tensor(data, mask)
>>> data.select(0, 1)
tensor([4., 5., 6., 7.])
>>> mask.select(0, 1)
tensor([False, True, False, False])
>>> mt.select(0, 1)
masked_tensor(
[ , 5.0000, , ]
)
Below is a list of the ops that are currently supported:

Returns a 1dimensional view of each input tensor with zero dimensions. 

Broadcasts the given tensors according to broadcastingsemantics. 

Broadcasts 

Concatenates the given sequence of 

Attempts to split a tensor into the specified number of chunks. 

Creates a new tensor by horizontally stacking the tensors in 

Splits 

Flattens 

Splits 

Stack tensors in sequence horizontally (column wise). 

Computes the Kronecker product, denoted by \(\otimes\), of 

Creates grids of coordinates specified by the 1D inputs in attr:tensors. 

Returns a new tensor that is a narrowed version of 

Return a contiguous flattened tensor. 

Slices the 

Splits the tensor into chunks. 

Expects 

Returns a tensor that is a transposed version of 

Splits 

Stack tensors in sequence vertically (row wise). 

Returns a new view of the 

Expand this tensor to the same size as 

Returns a tensor with the same data and number of elements as 

Returns this tensor as the same shape as 

Returns a new tensor with the same data as the 