Class Tensor


public class Tensor extends TensorManipulations
  • Constructor Details

    • Tensor

      public Tensor(int... shape)
    • Tensor

      public Tensor(int rows, int cols)
    • Tensor

      public Tensor(DType dtype, int... shape)
    • Tensor

      public Tensor(Tensor source)
  • Method Details

    • tensor

      protected Tensor tensor()
      Specified by:
      tensor in class TensorManipulations
    • requiresGrad

      public Tensor requiresGrad(boolean required)
    • grad

      public Tensor grad()
    • zeroGrad

      public void zeroGrad()
    • backward

      public void backward()
    • backward

      public void backward(Tensor gradient)
    • detach

      public Tensor detach()
      Independent detached storage, preserving DeepJ's existing copy-based detach behavior.
    • copy

      public Tensor copy()
      Bit-preserving independent storage with an identity autograd edge.
    • sumTensor

      public Tensor sumTensor()
    • item

      public float item()
    • retainDeviceBuffer

      public Tensor retainDeviceBuffer()
    • setBackend

      public static void setBackend(TensorBackend backend)
    • backend

      public static TensorBackend backend()
    • data

      public float[] data()
      Materializes and returns the backing FLOAT32 array of a full contiguous tensor.
    • rowData

      public float[] rowData(int r)
    • materialize

      public void materialize()
      Specified by:
      materialize in class TensorStorageAccess
    • matmul

      public Tensor matmul(Tensor other)
    • add

      public Tensor add(Tensor other)
    • subtract

      public Tensor subtract(Tensor other)
    • multiply

      public Tensor multiply(Tensor other)
    • divide

      public Tensor divide(Tensor other)
    • addRowVector

      public Tensor addRowVector(Tensor rowVector)
    • addBroadcastCols

      public Tensor addBroadcastCols(Tensor colVector)
    • divideBroadcastCols

      public Tensor divideBroadcastCols(Tensor colVector)
    • subtractBroadcastCols

      public Tensor subtractBroadcastCols(Tensor colVector)
    • multiplyBroadcastCols

      public Tensor multiplyBroadcastCols(Tensor colVector)
    • addBroadcastRows

      public Tensor addBroadcastRows(Tensor rowVector)
    • multiplyBroadcastRows

      public Tensor multiplyBroadcastRows(Tensor rowVector)
    • multiplyScalar

      public Tensor multiplyScalar(float s)
    • addScalar

      public Tensor addScalar(float s)
    • divideScalar

      public Tensor divideScalar(float s)
    • sumRows

      public Tensor sumRows()
    • sumAlongRows

      public Tensor sumAlongRows()
    • sumAlongCols

      public Tensor sumAlongCols()
    • meanAlongRows

      public Tensor meanAlongRows()
    • varianceAlongRows

      public Tensor varianceAlongRows()
    • transpose

      public Tensor transpose()
    • sqrt

      public Tensor sqrt()
    • neg

      public Tensor neg()
    • exp

      public Tensor exp()
    • log

      public Tensor log()
    • tanhActivation

      public Tensor tanhActivation()
    • sigmoidActivation

      public Tensor sigmoidActivation()
    • reluActivation

      public Tensor reluActivation()
    • geluActivation

      public Tensor geluActivation()
    • addInPlace

      public Tensor addInPlace(Tensor other)
    • subtractInPlace

      public Tensor subtractInPlace(Tensor other)
    • multiplyInPlace

      public Tensor multiplyInPlace(Tensor other)
    • divideInPlace

      public Tensor divideInPlace(Tensor other)
    • multiplyScalarInPlace

      public Tensor multiplyScalarInPlace(float scalar)
    • addScalarInPlace

      public Tensor addScalarInPlace(float scalar)
    • divideScalarInPlace

      public Tensor divideScalarInPlace(float scalar)
    • sqrtInPlace

      public Tensor sqrtInPlace()
    • negInPlace

      public Tensor negInPlace()
    • expInPlace

      public Tensor expInPlace()
    • logInPlace

      public Tensor logInPlace()
    • reluInPlace

      public Tensor reluInPlace()
    • geluInPlace

      public Tensor geluInPlace()
    • tanhInPlace

      public Tensor tanhInPlace()
    • sigmoidInPlace

      public Tensor sigmoidInPlace()
    • softmaxRows

      public Tensor softmaxRows()
    • adamWUpdate

      public static void adamWUpdate(Tensor w, Tensor g, Tensor mt, Tensor vt, float lr, float beta1, float beta2, float eps, float weightDecay, float bc1, float bc2)
    • maxAlongRows

      public Tensor maxAlongRows()
    • clamp

      public Tensor clamp(float min, float max)
    • pow

      public Tensor pow(float exponent)
    • scatterAddRows

      public static void scatterAddRows(Tensor target, int[] indices, Tensor grad)
    • from2D

      public static Tensor from2D(float[][] data)
    • from

      public static Tensor from(float[] values, int... shape)
    • from

      public static Tensor from(float[] values)
    • from

      public static Tensor from(float[] values, DType dtype)
    • from

      public static Tensor from(float[] values, DType dtype, int... shape)
    • sum

      public float sum()
    • sumAbs

      public float sumAbs()
    • crossEntropyLoss

      public float crossEntropyLoss(int[] targets)
    • getRow

      public Tensor getRow(int row)
    • setRow

      public void setRow(int row, Tensor source, int srcRow)
    • sliceRows

      public static Tensor sliceRows(Tensor t, int[] rowIndices, int cols)
    • sampleRows

      public static Tensor sampleRows(Tensor t, int n, Random rnd)
    • print

      public void print(String label)
    • zeros

      public static Tensor zeros(int rows, int cols)
    • ones

      public static Tensor ones(int rows, int cols)
    • random

      public static Tensor random(int rows, int cols, Random rand)
    • causalMask

      public static Tensor causalMask(int size)
    • requireSameShape

      public static void requireSameShape(Tensor a, Tensor b, String op)
    • requireTargetsMatchRows

      public static void requireTargetsMatchRows(Tensor logits, int[] targets)