public class RNNUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static SimpleMatrix |
concatenate(SimpleMatrix... vectors)
Concatenates several column vectors into one large column vector
|
static SimpleMatrix |
concatenateWithBias(SimpleMatrix... vectors)
Concatenates several column vectors into one large column
vector, adds a 1.0 at the end as a bias term
|
static SimpleMatrix |
elementwiseApplyLog(SimpleMatrix input)
Applies log to each of the entries in the matrix.
|
static SimpleMatrix |
elementwiseApplyTanh(SimpleMatrix input)
Applies tanh to each of the entries in the matrix.
|
static SimpleMatrix |
elementwiseApplyTanhDerivative(SimpleMatrix input)
Applies the derivative of tanh to each of the elements in the vector.
|
static double[] |
paramsToVector(double scale,
int totalSize,
java.util.Iterator<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<SimpleMatrix>... matrices)
Given a sequence of iterators over the matrices, builds a vector
out of those matrices in the order given.
|
static SimpleMatrix |
randomGaussian(int numRows,
int numCols,
java.util.Random rand)
Returns a vector with random Gaussian values, mean 0, std 1
|
static java.util.Map<java.lang.String,SimpleMatrix> |
readRawWordVectors(java.lang.String filename,
int expectedSize)
This method reads a file of raw word vectors, with a given expected size, and returns a map of word to vector.
|
static double |
sigmoid(double x)
Returns a sigmoid applied to the input
x. |
static SimpleMatrix |
softmax(SimpleMatrix input)
Applies softmax to all of the elements of the matrix.
|
static void |
vectorToParams(double[] theta,
java.util.Iterator<SimpleMatrix>... matrices)
Given a sequence of Iterators over SimpleMatrix, fill in all of
the matrices with the entries in the theta vector.
|
public static void vectorToParams(double[] theta,
java.util.Iterator<SimpleMatrix>... matrices)
public static double[] paramsToVector(int totalSize,
java.util.Iterator<SimpleMatrix>... matrices)
public static double[] paramsToVector(double scale,
int totalSize,
java.util.Iterator<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 java.util.Map<java.lang.String,SimpleMatrix> readRawWordVectors(java.lang.String filename,
int expectedSize)
WORD X1 X2 X3 ... public static double sigmoid(double x)
x.public static SimpleMatrix softmax(SimpleMatrix input)
public static SimpleMatrix elementwiseApplyLog(SimpleMatrix input)
public static SimpleMatrix elementwiseApplyTanh(SimpleMatrix input)
public static SimpleMatrix elementwiseApplyTanhDerivative(SimpleMatrix input)
public static SimpleMatrix concatenateWithBias(SimpleMatrix... vectors)
public static SimpleMatrix concatenate(SimpleMatrix... vectors)
public static SimpleMatrix randomGaussian(int numRows,
int numCols,
java.util.Random rand)