Package deepnetts.tensor
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
add
(float value, int row, int col) Adds specified value to matrix value at position x, yfinal Tensor2D
clone()
final int
cols()
copy()
void
void
void
Performs dot product operation on this tensor and matrib, and stores results in result tensor.dotProdFromCache
(Tensor1D vectorB, Tensor1D result) Performs dot product operation on this 2d tensor (matrix) and vector , and stores results in result tensor.static Tensor2D
final float
get
(int row, int col) Returns matrix value at row, colfloat[]
getCol
(int col, float[] colBuff) float[]
getColsCache
(int colIdx) float[]
getRow
(int row, float[] rowBuff) float[]
getRowsCache
(int rowIdx) final int
rows()
final void
set
(float val, int row, int col) Set value at specified [row, col] position.void
setCol
(int colIdx, float[] colData) void
setRow
(int rowIdx, float[] rowData) void
setValuesFromStringTransposed
(String values) final void
sub
(float val, int row, int col) toString()
Methods inherited from class deepnetts.tensor.TensorBase
add, add, addInto, apply, apply, copyFrom, copyFrom, copyFromGPU, copyToGPU, createAcceleratorBridge, div, div, div, equals, equals, fill, getAcceleratorBridge, getOrCreateAccBridge, getValues, hashCode, mean, multiply, multiply, multiplyElementWise, numDimensions, numElements, randomize, replace, setValues, setValuesFromString, shape, sqr, sqrt, std, sub, sub, subInplace, subInto, sum, sumAbs, sumSqr, 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 with specified values.- Parameters:
vals
- values to put into matrix
-
-
Method Details
-
cols
public final int cols() -
rows
public final int rows() -
get
public final float get(int row, int col) Returns matrix value at row, col- 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.- 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 row, 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:
copy
in classTensorBase
-
clone
- Overrides:
clone
in classTensorBase
-
getTransposed
-
setValuesFromStringTransposed
- Overrides:
setValuesFromStringTransposed
in classTensorBase
-
toString
- Overrides:
toString
in classTensorBase
-
fromFile
- Throws:
IOException
-
dotProd
-
dotProdFromCache
-
getRowsCache
public float[] getRowsCache(int rowIdx) -
getColsCache
public float[] getColsCache(int colIdx)
-