public class NeuralUtils extends 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(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 |
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 org.ejml.simple.SimpleMatrix |
loadTextMatrix(File file)
Convert a file into a text matrix.
|
static org.ejml.simple.SimpleMatrix |
loadTextMatrix(String path)
Convert a file into a text matrix.
|
static double[] |
paramsToVector(double scale,
int totalSize,
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,
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,
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 String |
toString(org.ejml.simple.SimpleMatrix matrix,
String format) |
static void |
vectorToParams(double[] theta,
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(String path)
public static org.ejml.simple.SimpleMatrix loadTextMatrix(File file)
public static org.ejml.simple.SimpleMatrix convertTextMatrix(String text)
public static String toString(org.ejml.simple.SimpleMatrix matrix, 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, Iterator<org.ejml.simple.SimpleMatrix>... matrices)
@SafeVarargs public static double[] paramsToVector(int totalSize, Iterator<org.ejml.simple.SimpleMatrix>... matrices)
@SafeVarargs public static double[] paramsToVector(double scale, int totalSize, 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 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,
Random rand)
public static boolean isZero(org.ejml.simple.SimpleMatrix matrix)