Class Tensor2D
java.lang.Object
deepnetts.tensor.TensorBase
deepnetts.tensor.Tensor2D
- All Implemented Interfaces:
Tensor, Serializable
A 2D tensor / matrix with specified number of rows and columns..
- See Also:
-
Field Summary
Fields inherited from class TensorBase
numDimensions, shape, values, vectorizationImpl -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidadd(float value, int row, int col) Adds specified value to matrix value at position x, yfinal Tensor2Dclone()final intcols()Returns a number of columns in this matrix.copy()voidvoidvoidstatic Tensor2Dfinal floatget(int row, int col) Returns a value at specified row, col position in this tensor.float[]getCol(int col, float[] colBuff) float[]getColsCache(int colIdx) float[]getRow(int rowIdx, float[] rowBuff) float[]getRowsCache(int rowIdx) Performs matrix multiplication with this 2d tensor and vector , and stores results in result tensor.Performs dot product operation on this tensor and matrib, and stores results in result tensor.matMulVectorized(Tensor1D vector, Tensor1D result) matMulVectorized(Tensor2D matrixB, Tensor2D result) voidouterProductAccumulate(Tensor2D inputs, Tensor2D result) final introws()Returns a number of rows in this matrix.final voidset(float val, int row, int col) Set value at specified [row, col] position in this tensor.voidsetCol(int colIdx, float[] colData) voidsetRow(int rowIdx, float[] rowData) voidsetThreadPool(DeepNettsThreadPool threadPool) voidsetValuesFromStringTransposed(String values) sqrSumByCol(Tensor1D sumSqr) final voidsub(float val, int row, int col) sumByColInto(Tensor1D sumTensor) voidtransposeInto(Tensor2D transposed) Methods inherited from class TensorBase
add, add, addInto, apply, apply, containsNaN, copyFrom, copyFrom, copyFromGPU, copyToGPU, createAcceleratorBridge, div, div, div, equals, equals, fill, getAcceleratorBridge, getOrCreateAccBridge, getValues, hashCode, mean, multiply, multiply, multiplyElementWise, numDimensions, numElements, randomize, replace, setShape, setValues, setValuesFromString, shape, sqr, sqrt, std, sub, sub, sub, subInplace, sum, sumAbs, sumSqr, toString, toTsr, valuesAsString
-
Constructor Details
-
Tensor2D
public Tensor2D(int rows, int cols) Creates a tensor with specified number of rows and columns (matrix).- Parameters:
rows- number of rowscols- number of columns
-
Tensor2D
public Tensor2D(int rows, int cols, float[] values) -
Tensor2D
public Tensor2D(float[][] vals) Creates a 2D tensor / matrix filled with given 2d array. First dimension corresponds to number of rows, while second dimension corresponds to number of columns.- Parameters:
vals- values to store into matrix
-
-
Method Details
-
cols
public final int cols()Returns a number of columns in this matrix.- Returns:
-
rows
public final int rows()Returns a number of rows in this matrix.- Returns:
-
get
public final float get(int row, int col) Returns a value at specified row, col position in this tensor.- Parameters:
row-col-- Returns:
- value at [row, col]
-
set
public final void set(float val, int row, int col) Set value at specified [row, col] position in this tensor.- Parameters:
val- value to setrow- tensor's row indexcol- tensor's col index
-
setRow
public void setRow(int rowIdx, float[] rowData) -
setCol
public void setCol(int colIdx, float[] colData) -
createRowsCache
public void createRowsCache() -
createColsCache
public void createColsCache() -
createRowsAndColsCache
public void createRowsAndColsCache() -
getRow
public float[] getRow(int rowIdx, float[] rowBuff) -
getCol
public float[] getCol(int col, float[] colBuff) -
add
public final void add(float value, int row, int col) Adds specified value to matrix value at position x, y- Parameters:
value-row-col-
-
add
-
sub
public final void sub(float val, int row, int col) -
copy
- Overrides:
copyin classTensorBase
-
clone
- Overrides:
clonein classTensorBase
-
getTransposed
-
transposeInto
-
setValuesFromStringTransposed
- Overrides:
setValuesFromStringTransposedin classTensorBase
-
fromFile
- Throws:
IOException
-
toFile
-
sqrSumByCol
-
matMul
-
matMul
-
getRowsCache
public float[] getRowsCache(int rowIdx) -
getColsCache
public float[] getColsCache(int colIdx) -
matMulVectorized
-
matMulVectorized
-
outerProductAccumulate
-
matMulMT
-
setThreadPool
-
sumByColInto
-