pose_format.tensorflow.masked.tensor module
Classes:
|
- class pose_format.tensorflow.masked.tensor.MaskedTensor(tensor, mask=None)[source]
Bases:
objectMethods:
arithmetic(action, other)For element-wise arithmetic operations with another tensor.
div(other[, in_place, update_mask])Divide tensor by another tensor.
fix_nan()Replace NaN values with zeros while keeping mask.
float()Convert tensor's data type to float32 while preserving mask.
gather(indexes)Gather elements from tensor using indexes.
matmul(matrix)Matrix multiplication a given matrix.
mean([axis])Compute mean of tensor along a custom axis.
permute(dims)Permute the dimensions of the tensor according to the provided tuple.
rename(*names)Rename using custom names.
reshape(shape)Reshape tensor into custom shape (tuple)
size(*args)Get tensor's size along dimensions.
split(split_size_or_sections[, axis])Split tensor
sqrt()Element-wise square root of the tensor
square()Element-wise square of the tensor.
squeeze(axis)Remove dimensions with size 1 while updating the mask.
std([axis])Compute the standard deviation of the tensor along the specified axis.
sum(axis)Sum of tensor along specified axis while updating mask.
transpose(perm)Transpose tensor according to given permutation.
variance([axis])Compute variance of tensor along a specified axis
Fill invalid values (as indicated by the mask) with zeros.
- Parameters:
tensor (Tensor) –
mask (Tensor) –
- arithmetic(action, other)[source]
For element-wise arithmetic operations with another tensor.
- Parameters:
action (str) – Name of the arithmetic operation
other (
pose_format.tensorflow.masked.tensor.MaskedTensoror tf.Tensor) – Tensor or MaskedTensor to perform the operation with.
- Returns:
A new MaskedTensor containing the result of the arithmetic operation.
- Return type:
- div(other, in_place=False, update_mask=True)[source]
Divide tensor by another tensor.
- Parameters:
other (
pose_format.tensorflow.masked.tensor.MaskedTensor) – The divisor tensor.in_place (bool, optional) – Whether to do division in place. Default is False.
update_mask (bool, optional) – Whether to update mask after division. Default is True.
- Returns:
Masked tensor after division.
- Return type:
- fix_nan()[source]
Replace NaN values with zeros while keeping mask.
- Returns:
New MaskedTensor with NaN values replaced by zeros.
- Return type:
- float()[source]
Convert tensor’s data type to float32 while preserving mask.
- Returns:
A new MaskedTensor with the tensor’s data type converted to float32.
- Return type:
- gather(indexes)[source]
Gather elements from tensor using indexes.
- Parameters:
indexes (tf.Tensor or list or int) – Indexes used to select elements from tensor
- Returns:
A new MaskedTensor containing elements gathered from the tensor using the indexes.
- Return type:
- matmul(matrix)[source]
Matrix multiplication a given matrix.
- Parameters:
matrix (tf.Tensor) – Matrix to perform multiplication with.
- Returns:
MaskedTensor` with result of matrix multiplication.
- Return type:
- mean(axis=None)[source]
Compute mean of tensor along a custom axis.
- Parameters:
axis (None or int, optional) – Sxis along which to compute the mean. If None, compute the mean of the entire tensor. Default is None.
- Returns:
The mean of the masked tensor.
- Return type:
- permute(dims)[source]
Permute the dimensions of the tensor according to the provided tuple.
- Parameters:
dims (tuple) – The new order of dimensions after permutation.
- Returns:
A new MaskedTensor with dimensions permuted according to the given tuple.
- Return type:
- rename(*names)[source]
Rename using custom names.
- Parameters:
*names (str) – New names of the dimensions.
- Returns:
A new MaskedTensor with dimensions renamed.
- Return type:
- reshape(shape)[source]
Reshape tensor into custom shape (tuple)
- Parameters:
shape (tuple) – New shape of tensor.
- Returns:
new MaskedTensor with specified shape.
- Return type:
- size(*args)[source]
Get tensor’s size along dimensions.
- Parameters:
*args (int) – Dimensions for which to get size
- Returns:
Size of tensor of specified dimensions.
- Return type:
int or tuple of int
- split(split_size_or_sections, axis=0)[source]
Split tensor
- Parameters:
split_size_or_sections (int or tf.Tensor) – Number of splits or sizes of each split/sections.
axis (int, optional) – Axis along which to do the splitting. Default is 0.
- Returns:
List of new MaskedTensor objects containing the splits.
- Return type:
- sqrt()[source]
Element-wise square root of the tensor
- Returns:
A new MaskedTensor containing the square root values of the original tensor.
- Return type:
- square()[source]
Element-wise square of the tensor.
- Returns:
A new MaskedTensor containing the squared values of the original tensor.
- Return type:
- squeeze(axis)[source]
Remove dimensions with size 1 while updating the mask.
- Parameters:
axis (int or None) – The axis along which to perform squeezing.
- Returns:
MaskedTensor` with dimensions removed and mask updated.
- Return type:
- std(axis=None)[source]
Compute the standard deviation of the tensor along the specified axis.
- Parameters:
axis (None or int, optional) – The axis along which to compute the standard deviation. If None, compute the standard deviation of the entire tensor. Default is None.
- Returns:
The standard deviation of the tensor.
- Return type:
- sum(axis)[source]
Sum of tensor along specified axis while updating mask.
- Parameters:
axis (int or None) – Axis along which to compute sum. If None, compute the sum over all elements.
- Returns:
A new MaskedTensor containing the sums of the tensor along the specified axis.
- Return type:
- transpose(perm)[source]
Transpose tensor according to given permutation.
- Parameters:
perm (List[int]) – The new order of dimensions/permutation after transposition.
- Returns:
MaskedTensor with dimensions transposed according to the given permutation.
- Return type: