emloop_tensorflow.ops

Module with custom TF ops.

Functions

  • repeat(): Repeat elements of the input tensor in the specified axis repeats-times.
  • flatten3D(): Flatten the given inputs tensor to 3 dimensions.
  • dense_to_sparse(): Convert the given inputs tensor to a SparseTensor of its non-zero values.
  • smooth_l1_loss(): Calculate piece-wise smooth L1 loss on the given tensors.
  • get_last_valid_features(): Get the last valid values from the given feature sequences.
emloop_tensorflow.ops.repeat(tensor, repeats, axis)[source]

Repeat elements of the input tensor in the specified axis repeats-times.

Note

Chaining of this op may produce TF warnings although the performance seems to be unaffected.

Parameters:
  • tensor (Tensor) – TF tensor to be repeated
  • repeats (int) – number of repeats
  • axis (int) – axis to repeat
Return type:

Tensor

Returns:

tensor with repeated elements

emloop_tensorflow.ops.flatten3D(inputs)[source]

Flatten the given inputs tensor to 3 dimensions.

Parameters:inputs (Tensor) – >=3d tensor to be flattened
Return type:Tensor
Returns:3d flatten tensor
emloop_tensorflow.ops.dense_to_sparse(inputs, mask=None)[source]

Convert the given inputs tensor to a SparseTensor of its non-zero values.

Optionally, use the given mask tensor for determining the values to be included in the SparseTensor.

Parameters:
  • inputs (Tensor) – input dense tensor
  • mask (Optional[Tensor]) – optional mask tensor
Return type:

SparseTensor

Returns:

sparse tensor of non-zero (or masked) values

emloop_tensorflow.ops.smooth_l1_loss(predicted, expected)[source]

Calculate piece-wise smooth L1 loss on the given tensors.

Reference: Fast R-CNN

Parameters:
  • predicted (Tensor) – predicted values tensor
  • expected (Tensor) – expected values tensor with the same shape as the predicted tensor
Return type:

Tensor

Returns:

piece-wise smooth L1 loss

emloop_tensorflow.ops.get_last_valid_features(features, sequence_lengths)[source]

Get the last valid values from the given feature sequences.

Parameters:
  • features (Tensor) – 3-dim batch-major tensor [batch, max_time, features]
  • sequence_lengths (Tensor) – 1-dim tensor with sequence_lengths
Return type:

Tensor

Returns:

last valid features, 2-dim tensor [batch, features]