public class NeuralUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static org.ejml.simple.SimpleMatrix |
concatenate(org.ejml.simple.SimpleMatrix... vectors)
Concatenates several column vectors into one large column vector
|
static org.ejml.simple.SimpleMatrix |
concatenateWithBias(org.ejml.simple.SimpleMatrix... vectors)
Concatenates several column vectors into one large column
vector, adds a 1.0 at the end as a bias term
|
static org.ejml.simple.SimpleMatrix |
convertTextMatrix(java.lang.String text) |
static double |
cosine(org.ejml.simple.SimpleMatrix vector1,
org.ejml.simple.SimpleMatrix vector2)
Compute cosine distance between two column vectors.
|
static double |
dot(org.ejml.simple.SimpleMatrix vector1,
org.ejml.simple.SimpleMatrix vector2)
Compute dot product between two vectors.
|
static org.ejml.simple.SimpleMatrix |
elementwiseApplyLog(org.ejml.simple.SimpleMatrix input)
Applies log to each of the entries in the matrix.
|
static org.ejml.simple.SimpleMatrix |
elementwiseApplyReLU(org.ejml.simple.SimpleMatrix input)
Applies ReLU to each of the entries in the matrix.
|
static org.ejml.simple.SimpleMatrix |
elementwiseApplyTanh(org.ejml.simple.SimpleMatrix input)
Applies tanh to each of the entries in the matrix.
|
static org.ejml.simple.SimpleMatrix |
elementwiseApplyTanhDerivative(org.ejml.simple.SimpleMatrix input)
Applies the derivative of tanh to each of the elements in the vector.
|
static boolean |
isZero(org.ejml.simple.SimpleMatrix matrix)
Returns true iff every element of matrix is 0
|
static java.util.List<org.ejml.simple.SimpleMatrix> |
loadTextMatrices(java.lang.String path)
Convert a file into a list of matrices.
|
static org.ejml.simple.SimpleMatrix |
loadTextMatrix(java.io.File file)
Convert a file into a text matrix.
|
static org.ejml.simple.SimpleMatrix |
loadTextMatrix(java.lang.String path)
Convert a file into a text matrix.
|
static org.ejml.simple.SimpleMatrix |
oneHot(int index,
int size) |
static double[] |
paramsToVector(double scale,
int totalSize,
java.util.Iterator<org.ejml.simple.SimpleMatrix>... matrices)
Given a sequence of iterators over the matrices, builds a vector
out of those matrices in the order given.
|
static double[] |
paramsToVector(int totalSize,
java.util.Iterator<org.ejml.simple.SimpleMatrix>... matrices)
Given a sequence of iterators over the matrices, builds a vector
out of those matrices in the order given.
|
static org.ejml.simple.SimpleMatrix |
randomGaussian(int numRows,
int numCols,
java.util.Random rand)
Returns a vector with random Gaussian values, mean 0, std 1
|
static double |
sigmoid(double x)
Returns a sigmoid applied to the input
x. |
static org.ejml.simple.SimpleMatrix |
softmax(org.ejml.simple.SimpleMatrix input)
Applies softmax to all of the elements of the matrix.
|
static java.lang.String |
toString(org.ejml.simple.SimpleMatrix matrix,
java.lang.String format) |
static void |
vectorToParams(double[] theta,
java.util.Iterator<org.ejml.simple.SimpleMatrix>... matrices)
Given a sequence of Iterators over SimpleMatrix, fill in all of
the matrices with the entries in the theta vector.
|
public static org.ejml.simple.SimpleMatrix loadTextMatrix(java.lang.String path)
public static org.ejml.simple.SimpleMatrix loadTextMatrix(java.io.File file)
public static java.util.List<org.ejml.simple.SimpleMatrix> loadTextMatrices(java.lang.String path)
public static org.ejml.simple.SimpleMatrix convertTextMatrix(java.lang.String text)
public static java.lang.String toString(org.ejml.simple.SimpleMatrix matrix,
java.lang.String format)
matrix - The matrix to return as a Stringformat - The format to use for each value in the matrix, eg "%f"public static double cosine(org.ejml.simple.SimpleMatrix vector1,
org.ejml.simple.SimpleMatrix vector2)
public static double dot(org.ejml.simple.SimpleMatrix vector1,
org.ejml.simple.SimpleMatrix vector2)
@SafeVarargs
public static void vectorToParams(double[] theta,
java.util.Iterator<org.ejml.simple.SimpleMatrix>... matrices)
@SafeVarargs
public static double[] paramsToVector(int totalSize,
java.util.Iterator<org.ejml.simple.SimpleMatrix>... matrices)
@SafeVarargs
public static double[] paramsToVector(double scale,
int totalSize,
java.util.Iterator<org.ejml.simple.SimpleMatrix>... matrices)
scale parameter. Asks for an
expected total size as a time savings. AssertionError thrown if
the vector sizes do not exactly match.public static double sigmoid(double x)
x.public static org.ejml.simple.SimpleMatrix softmax(org.ejml.simple.SimpleMatrix input)
public static org.ejml.simple.SimpleMatrix elementwiseApplyReLU(org.ejml.simple.SimpleMatrix input)
public static org.ejml.simple.SimpleMatrix elementwiseApplyLog(org.ejml.simple.SimpleMatrix input)
public static org.ejml.simple.SimpleMatrix elementwiseApplyTanh(org.ejml.simple.SimpleMatrix input)
public static org.ejml.simple.SimpleMatrix elementwiseApplyTanhDerivative(org.ejml.simple.SimpleMatrix input)
public static org.ejml.simple.SimpleMatrix concatenateWithBias(org.ejml.simple.SimpleMatrix... vectors)
public static org.ejml.simple.SimpleMatrix concatenate(org.ejml.simple.SimpleMatrix... vectors)
public static org.ejml.simple.SimpleMatrix randomGaussian(int numRows,
int numCols,
java.util.Random rand)
public static org.ejml.simple.SimpleMatrix oneHot(int index,
int size)
public static boolean isZero(org.ejml.simple.SimpleMatrix matrix)