VariableTensor
Implementation of a variable tensor class to efficiently store tensors of varying lengths.
VariableTensor:__init(opt)
Constructor.
Arguments:
preinit_size(int): how many indices to preallocate for. Optional, Default:1.preinit_store_size(int): how many elements to preallocate for. Optional, Default:1.
VariableTensor:cuda()
Moves the storage to cuda
Returns:
- (
VariableTensor) modified tensor
VariableTensor:size()
Returns:
- (
int) sum of the size of each tensor in the storage
VariableTensor:push(tensor)
Appends a tensor to the storage.
Arguments:
tensor(torch.Tensor): tensor to add to storage.
Returns:
- (
VariableTensor) modified tensor
VariableTensor:shuffle(indices)
Shuffles the indices.
Arguments:
indices(torch.Tensor): tensor that denotes how the new indices should be set. If not given, then a random tensor will be generated. Optional.
Returns:
- (
torch.Tensor) theindicestensor used to shuffle
VariableTensor:get(i)
Retrieves the tensor at index i.
Arguments:
i(int): index to query.
Returns:
- (
torch.Tensor) tensor at index
VariableTensor:batch(indices, pad)
Creates a zero-padded batch from tensors at the indices indices.
Arguments:
indices(table): starting indices of tensors to pad.pad(int): number to use to pad shorter tensors. Optional, Default:0.