Package deepboof.misc

Class TensorOps_F64

java.lang.Object
deepboof.misc.TensorOps_F64

public class TensorOps_F64
extends Object
  • Constructor Details

    • TensorOps_F64

      public TensorOps_F64()
  • Method Details

    • elementMult

      public static void elementMult​(Tensor_F64 tensor, double value)
      Performs an element-wise scalar multiplication on the tensor
      Parameters:
      tensor - Tensor which is multiplied
      value - value of the multiplication
    • elementMult

      public static void elementMult​(Tensor_F64 input, double value, Tensor_F64 output)
      Performs an element-wise scalar multiplication
      Parameters:
      input - Tensor which is multiplied (not modified)
      value - value of the multiplication (modified)
      output - Tensor where the results are stored
    • elementMult

      public static void elementMult​(Tensor_F64 A, Tensor_F64 B, Tensor_F64 output)

      Performs element-wise multiplication between the two tensors and stores results in output. All tensors must have the same shape.

      output[i] = A[i]*B[i]
      Parameters:
      A - Input tensor. Can be the same as output.
      B - Input tensor. Can be the same as output.
      output - Output tensor.
    • elementAdd

      public static void elementAdd​(Tensor_F64 A, Tensor_F64 B, Tensor_F64 output)

      Performs element-wise addition between the two tensors and stores results in output. All tensors must have the same shape.

      output[i] = A[i] + B[i]
      Parameters:
      A - Input tensor. Can be the same as output.
      B - Input tensor. Can be the same as output.
      output - Output tensor.
    • elementSum

      public static double elementSum​(Tensor_F64 tensor)
      Computes the sum of all the elements in the tensor
      Parameters:
      tensor - Tensor
    • insertSubChannel

      public static void insertSubChannel​(Tensor_F64 src, int srcStartIndex, int srcStride, Tensor_F64 dst, int dstStartIndex, int dstStride, int rows, int columns)
      Used to copy a sub-image between two image tensors.
      Parameters:
      src - Source tensor
      srcStartIndex - Start index in input tensor.
      srcStride - Row-stride for input tensor
      dst - Destination tensor
      dstStartIndex - Start index in destination tensor.
      dstStride - Row-stride for destination tensor
      rows - Number of rows to be copied
      columns - Number of columns to be copied
    • insertSpatial

      public static void insertSpatial​(Tensor_F64 src, int[] srcCoor, Tensor_F64 dst, int[] dstCoor)
      Inserts the spatial region of one tensor into another. Both tensors are assumed to follow the following pattern for their shape. (..., C, H, W). C is for the number of channels, H is for the image's height, and W, is for the image's width.
      Parameters:
      src - Source tensor. Entire image is copied into dst.
      srcCoor - Coordinate of spatial region. ( ..., 0, 0, 0) modified.
      dst - Destination tensor. The source image can be smaller than the destination, but not larger.
      dstCoor - Coordinate of spatial region. ( ..., 0, y, x) modified.
    • fillSpatialBorder

      public static void fillSpatialBorder​(Tensor_F64 tensor, int[] coor, int borderY0, int borderX0, int borderY1, int borderX1, double value)
      Fills the border with the specified value. The tensor is assumed to have the following shape ( ... , C , H, W), C is for he number of channels, H is for the image's height, and W, is for the image's width.
      Parameters:
      tensor - Tensor with a spatial region at the end. Modified.
      coor - Coordinate of the targeted spatial region inside the tensor. axis values for C,H,W are ignored. Modified.
      borderY0 - Lower extent's border length along Y axis
      borderX0 - Lower extent's border length along X axis
      borderY1 - Upper extent's border length along Y axis
      borderX1 - Upper extent's border length along X axis
      value - Value that is to be inserted
    • printSpatial

      public static void printSpatial​(Tensor_F64 tensor, int batch, int channel)
      Prints a single batch and channel in a spatial tensor
      Parameters:
      tensor - The tensor
      batch - Batch number
      channel - channel
    • fill

      public static void fill​(Tensor_F64 tensor, double value)
      Fills the tensor with the specified value
      Parameters:
      tensor - The tensor
      value - fill value