Class Tensor3D

All Implemented Interfaces:
Tensor, Serializable

public class Tensor3D extends TensorBase
A 3D tensor/matrix, with rows, columns and depth.
See Also:
  • Constructor Details

    • Tensor3D

      public Tensor3D(int depth, int rows, int cols)
      Creates a new 3D tensor with specified number of rows, columns and depth.
      Parameters:
      depth - tensor depth
      rows - number of rows
      cols - number of columns
    • Tensor3D

      public Tensor3D(float[][][] vals)
      Creates a 3D tensor from specified 3D array
      Parameters:
      vals - 2D array of tensor values
    • Tensor3D

      public Tensor3D(int depth, int rows, int cols, float[] values)
  • Method Details

    • get

      public final float get(int ch, int row, int col)
    • set

      public final void set(float val, int ch, int row, int col)
    • add

      public final void add(float value, int z, int row, int col)
    • sub

      public final void sub(float val, int z, int row, int col)
    • copy

      public TensorBase copy()
      Overrides:
      copy in class TensorBase
    • cols

      public final int cols()
    • rows

      public final int rows()
    • depth

      public final int depth()
    • copy2DSubChannel

      public final void copy2DSubChannel(int ch, float[] buff)
      Copies 2D channel values from this tensor into given float array buffer. Used on 3D tensors.
      Parameters:
      ch - tensor channel to copy
      buff - buffer to copy values into
    • setRow

      public void setRow(float[] rowData, int depthIdx, int rowIdx)
    • channelMean

      public float channelMean(int ch)
    • divChannel

      public void divChannel(float val, int ch)
    • fromFile

      public static Tensor3D fromFile(String filePath) throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class TensorBase
    • toFile

      public void toFile(String filePath) throws IOException
      Throws:
      IOException