public class TensorOps
extends java.lang.Object
| Constructor and Description |
|---|
TensorOps() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends Tensor> |
AD(T input)
Adds a dimension to the input tensor.
|
static void |
boundSpatial(int[] bounds,
int rows,
int cols) |
static void |
checkShape(java.lang.String which,
int tensor,
int[] expected,
int[] actual,
boolean ignoreAxis0)
Checks to see if the two tensors have the same shape, with the option to ignore the first axis for the 'actual'
shape.
|
static void |
checkShape(java.lang.String which,
java.util.List<int[]> expected,
java.util.List<Tensor<?>> actual,
boolean ignoreAxis0)
Compares a list of tensors shape's against each other.
|
static void |
checkShape(Tensor_F32 a,
Tensor_F32 b)
Checks to see if the two tensors have the same shape
|
static void |
checkShape(Tensor_F64 a,
Tensor_F64 b)
Checks to see if the two tensors have the same shape
|
static double |
elementSum(Tensor tensor)
Computes the sum of all the elements in the tensor
|
static void |
fill(Tensor t,
double value) |
static int |
outerLength(int[] shape,
int startDimen)
Computes the number of elements for an inner portion of the tensor starting at
the specified index and going outside
|
static java.io.File |
pathToRoot() |
static int |
sumTensorLength(java.util.List<int[]> shapes)
Returns the total length of all the tensors in the list summed together
|
static int |
tensorLength(int... shape)
Returns the total length of one tensor
|
static int[] |
TH(int[] elements)
Truncates the head (element 0) from the array
|
static java.lang.String |
toStringShape(int[] shape) |
static java.lang.String |
toStringShapeA(int[] shape) |
static int[] |
WI(int... elements)
Convenience function for making it easy to create an array of ints
|
static int[] |
WI(int[] elements,
int a)
Convenience function for making it easy to create an array of ints
|
static int[] |
WI(int a,
int[] elements)
Convenience function for making it easy to create an array of ints
|
static java.util.List<int[]> |
WI(int a,
java.util.List<int[]> list) |
static <T> java.util.List<T> |
WT(T... elements)
Convenience function for wrapping passed in elements into a list
|
public static <T> java.util.List<T> WT(T... elements)
public static int[] WI(int... elements)
public static int[] WI(int a,
int[] elements)
public static int[] WI(int[] elements,
int a)
public static int[] TH(int[] elements)
public static java.util.List<int[]> WI(int a,
java.util.List<int[]> list)
public static <T extends Tensor> T AD(T input)
public static int sumTensorLength(java.util.List<int[]> shapes)
shapes - List of tensor shapespublic static int tensorLength(int... shape)
shape - shape of a tensorpublic static void checkShape(java.lang.String which,
java.util.List<int[]> expected,
java.util.List<Tensor<?>> actual,
boolean ignoreAxis0)
checkShape(String, int, int[], int[], boolean)which - String describing which variables are being checkedexpected - List of expected tensorsactual - List of actual tensors. Axis 0 is optionally ignored here, see ignoreAxis0ignoreAxis0 - true to ignore axis 0public static void checkShape(Tensor_F64 a, Tensor_F64 b)
a - tensorb - tensorpublic static void checkShape(Tensor_F32 a, Tensor_F32 b)
a - tensorb - tensorpublic static void checkShape(java.lang.String which,
int tensor,
int[] expected,
int[] actual,
boolean ignoreAxis0)
IllegalArgumentException if they don't match.which - String describing which variable is being checkedtensor - Index of the tensor in a tensor list. Used to provide a more detailed error message.
If < 0 then this is ignoredexpected - Expected shape.actual - Actual shape. Axis 0 is optionally ignored.ignoreAxis0 - If true it will ignore the first dimension in expectedpublic static java.lang.String toStringShapeA(int[] shape)
public static java.lang.String toStringShape(int[] shape)
public static int outerLength(int[] shape,
int startDimen)
Computes the number of elements for an inner portion of the tensor starting at the specified index and going outside
Example:public static java.io.File pathToRoot()
public static double elementSum(Tensor tensor)
tensor - Tensorpublic static void fill(Tensor t, double value)
public static void boundSpatial(int[] bounds,
int rows,
int cols)