Class Tensor
java.lang.Object
io.github.kirstenali.deepj.tensor.Tensor
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadamWUpdate(Tensor w, Tensor g, Tensor mt, Tensor vt, double lr, double beta1, double beta2, double eps, double weightDecay, double bc1, double bc2) addBroadcastCols(Tensor colVector) addBroadcastRows(Tensor rowVector) addInPlace(Tensor b) addRowVector(Tensor rowVector) addScalar(double s) addScalarInPlace(double s) static TensorBackendbackend()static TensorcausalMask(int size) clamp(double min, double max) crossEntropyGradient(int[] targets) doublecrossEntropyLoss(int[] targets) divideBroadcastCols(Tensor colVector) divideScalar(double s) divideScalarInPlace(double s) exp()static double[]geluBackward(Tensor gradOutput) doubleget(int r, int c) Get the GPU handle (used by GPU backends).getRow(int row) static TensorlayerNormBackward(Tensor dXHat, Tensor xHat, Tensor std, int dim) log()voidEnsures this tensor'sdata[][]is up to date with any pending GPU computation.multiplyBroadcastCols(Tensor colVector) multiplyBroadcastRows(Tensor rowVector) multiplyScalar(double s) multiplyScalarInPlace(double s) neg()static Tensorones(int rows, int cols) pow(double exponent) voidstatic TensorreluBackward(Tensor gradOutput) static voidrequireSameShape(Tensor a, Tensor b, String op) static voidrequireTargetsMatchRows(Tensor logits, int[] targets) static TensorsampleRows(Tensor t, int n, Random rnd) static voidscatterAddRows(Tensor target, int[] indices, Tensor grad) voidset(int r, int c, double value) static voidsetBackend(TensorBackend backend) voidSet the GPU handle (used by GPU backends).voidstatic TensorsoftmaxBackward(Tensor softmaxOut) sqrt()subtractBroadcastCols(Tensor colVector) doublesum()doublesumAbs()sumRows()static TensorunflattenToTensor(double[] flat, int rows, int cols) static Tensorzeros(int rows, int cols)
-
Field Details
-
data
public final double[][] data -
rows
public final int rows -
cols
public final int cols
-
-
Constructor Details
-
Tensor
public Tensor(int rows, int cols) -
Tensor
public Tensor(double[][] data)
-
-
Method Details
-
getGpuTag
Get the GPU handle (used by GPU backends). -
setGpuTag
Set the GPU handle (used by GPU backends). -
setBackend
-
backend
-
materialize
public void materialize()Ensures this tensor'sdata[][]is up to date with any pending GPU computation. No-op if this tensor has no GPU handle or is already materialized. Call this before readingdata[][]directly. -
matmul
-
add
-
subtract
-
multiply
-
divide
-
addRowVector
-
addBroadcastCols
-
divideBroadcastCols
-
subtractBroadcastCols
-
multiplyBroadcastCols
-
addBroadcastRows
-
multiplyBroadcastRows
-
multiplyScalar
-
addScalar
-
divideScalar
-
sumRows
-
sumAlongRows
-
sumAlongCols
-
meanAlongRows
-
varianceAlongRows
-
maxAlongRows
-
sum
public double sum() -
sumAbs
public double sumAbs() -
clamp
-
transpose
-
sqrt
-
pow
-
neg
-
exp
-
log
-
tanhActivation
-
sigmoidActivation
-
reluActivation
-
reluBackward
-
geluActivation
-
geluBackward
-
addInPlace
-
subtractInPlace
-
multiplyInPlace
-
divideInPlace
-
multiplyScalarInPlace
-
addScalarInPlace
-
divideScalarInPlace
-
sqrtInPlace
-
negInPlace
-
expInPlace
-
logInPlace
-
reluInPlace
-
geluInPlace
-
tanhInPlace
-
sigmoidInPlace
-
softmaxRows
-
softmaxBackward
-
crossEntropyLoss
public double crossEntropyLoss(int[] targets) -
crossEntropyGradient
-
adamWUpdate
-
layerNormBackward
-
get
public double get(int r, int c) -
set
public void set(int r, int c, double value) -
getRow
-
setRow
-
sliceRows
-
scatterAddRows
-
sampleRows
-
print
-
zeros
-
ones
-
random
-
causalMask
-
unflattenToTensor
-
flattenTensor
-
requireSameShape
-
requireTargetsMatchRows
-