Package deepboof

Class BaseTensor

java.lang.Object
deepboof.BaseTensor
All Implemented Interfaces:
ITensor
Direct Known Subclasses:
BaseSpatialPadding2D, Tensor

public abstract class BaseTensor
extends Object
implements ITensor
Base class for all Tensor data types. Only provides information dealing with the tensor's shape and core data type.
  • Field Summary

    Fields
    Modifier and Type Field Description
    int[] shape
    The lengths of each dimension/axis.
  • Constructor Summary

    Constructors
    Constructor Description
    BaseTensor()  
  • Method Summary

    Modifier and Type Method Description
    int[] createCoor()
    Creates a new coordinate for this tensor.
    int getDimension()
    Returns the number of dimensions in the tensor
    int[] getShape()
    Returns the internal array that specifies the tensor's shape.
    boolean isShape​(int... shape)
    Checks to see if the supplied shape is the same as the tensor's shape
    int length​(int dimension)
    Returns the length of a dimension/axis.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface deepboof.ITensor

    getDataType
  • Field Details

    • shape

      public int[] shape
      The lengths of each dimension/axis. Highest stride to smallest stride.
  • Constructor Details

    • BaseTensor

      public BaseTensor()
  • Method Details

    • getShape

      public int[] getShape()
      Returns the internal array that specifies the tensor's shape. DO NOT MODIFIY
      Specified by:
      getShape in interface ITensor
      Returns:
      int[] array of the shape
    • isShape

      public boolean isShape​(int... shape)
      Checks to see if the supplied shape is the same as the tensor's shape
      Specified by:
      isShape in interface ITensor
      Parameters:
      shape - int[] which specifies the shape ofa tensor
      Returns:
      true if the same or false if not
    • length

      public int length​(int dimension)
      Returns the length of a dimension/axis. If a negative number is passed in it will return the distance relative to the end. E.g. -1 = length-1, -2 = length-2
      Specified by:
      length in interface ITensor
      Parameters:
      dimension - The dimension/axis
      Returns:
      length
    • createCoor

      public int[] createCoor()
      Creates a new coordinate for this tensor.
      Specified by:
      createCoor in interface ITensor
      Returns:
      coordinate/int array of appropriate length
    • getDimension

      public int getDimension()
      Returns the number of dimensions in the tensor
      Specified by:
      getDimension in interface ITensor
      Returns:
      number of dimensions