Package deepnetts.tensor
Class Tensors
java.lang.Object
deepnetts.tensor.Tensors
-
Method Summary
Modifier and TypeMethodDescriptionstatic float[]
absMax
(float[] arr, float[] max) Returns array with max values for each position in the given input vectors.static TensorBase
absMax
(TensorBase t, TensorBase max) Returns tensors with max value for each component of input tensors.static float[]
absMin
(float[] arr, float[] min) static TensorBase
absMin
(TensorBase t, TensorBase min) static final void
add
(float[] array1, float[] array2) Adds given vector and store result in first.static final void
copy
(float[] src, float[] dest) static final void
copy
(TensorBase src, TensorBase dest) static float[]
copyOf
(float[] arr) static Tensor2D
create
(int rows, int cols, float[] values) Factory method for creating tensor instance,static Tensor3D
create
(int depth, int rows, int cols, float[] values) static Tensor4D
create
(int fourthDim, int depth, int rows, int cols, float[] values) static void
div
(float[] array, float val) static void
div
(float[] array, float[] divisor) static Tensor1D
dotProduct
(Tensor2D matrixA, Tensor1D vectorB, Tensor1D resultC) Dot product matrix vector multiplication C = A .static void
dotProduct
(Tensor2D matrixA, Tensor2D matrixB, Tensor2D result) static void
dotProductBuffered
(Tensor2D matrixA, Tensor1D vectorB, Tensor1D resultC) Matrix vector dot product.static void
dotProductBuffered
(Tensor2D matrixA, Tensor2D matrixB, Tensor2D result) static void
fillFourthDim
(Tensor4D deltaWeights, int fourthIdx, float val) static TensorBase
static void
max
(TensorBase t1, TensorBase t2, TensorBase result) static void
min
(TensorBase t1, TensorBase t2, TensorBase result) static void
multiply
(float[] arr1, float[] arr2) static Tensor1D
ones
(int size) static float[]
parseFloats
(String str) static int[]
static Tensor1D
random
(int size) Generates a random 1D tensor with the specified dimensions.static Tensor2D
random
(int rows, int cols) Create and return a tensor with specified number of rows and cols filled with random values.static Tensor3D
random
(int depth, int rows, int cols) static Tensor4D
random
(int fourthDim, int depth, int rows, int cols) static void
sub
(float[] arr, float val) static final void
sub
(float[] array1, float[] array2) static Tensor1D
zeros
(int size)
-
Method Details
-
copyOf
public static float[] copyOf(float[] arr) -
copy
-
copy
public static final void copy(float[] src, float[] dest) -
sub
public static void sub(float[] arr, float val) -
multiply
public static void multiply(float[] arr1, float[] arr2) -
fillFourthDim
-
absMax
Returns tensors with max value for each component of input tensors.- Parameters:
t
-max
- proposed max tensor- Returns:
- tensor with max value for each component
-
absMax
public static float[] absMax(float[] arr, float[] max) Returns array with max values for each position in the given input vectors. Stores max values in second parameter.- Parameters:
arr
-max
-- Returns:
-
absMin
-
absMin
public static float[] absMin(float[] arr, float[] min) -
div
public static void div(float[] array, float val) -
div
public static void div(float[] array, float[] divisor) -
dotProduct
-
dotProductBuffered
-
dotProduct
-
dotProductBuffered
-
sub
public static final void sub(float[] array1, float[] array2) -
add
public static final void add(float[] array1, float[] array2) Adds given vector and store result in first.- Parameters:
array1
-array2
-
-
zeros
-
ones
-
random
Generates a random 1D tensor with the specified dimensions. Random values are uniformly distributed in range [0, 1]- Parameters:
size
- size of the 1 dim tensor- Returns:
- 1D tensor filled with random values from global random num generator.
-
random
Create and return a tensor with specified number of rows and cols filled with random values.- Parameters:
rows
- number of rowscols
- number of columns- Returns:
- a random tensor of specificed dimensions
-
random
-
random
-
min
-
max
-
create
Factory method for creating tensor instance,- Parameters:
rows
-cols
-values
-- Returns:
-
create
-
create
-
fromFile
- Throws:
IOException
-
parseInts
-
parseFloats
-