Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created Mar 10, 2018
Embed
What would you like to do?
public class RNN
{
private Matrix<double> _state;
private Matrix<double> _inputWeights;
private Matrix<double> _recurrentWeights;
private Matrix<double> _outputWeights;
public RNN(Matrix<double> initialInputWeights, Matrix<double> initialReccurentWeights, Matrix<double> initialOutputWeights)
{
_inputWeights = initialInputWeights;
_recurrentWeights = initialReccurentWeights;
_outputWeights = initialOutputWeights;
}
public Matrix<double> TimeStep(Matrix<double> input)
{
_state = Matrix<double>.Tanh(_state.Multiply(_recurrentWeights) + input.Multiply(_inputWeights));
return _state.Multiply(_outputWeights);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment