December 2019
Intermediate to advanced
468 pages
14h 28m
English
The preceding example has an issue, though. Let's run the training process with a longer sequence:
x = np.array([[0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0]])y = np.array([12])losses, gradients_u, gradients_w = train(x, y, epochs=150)plot_training(losses, gradients_u, gradients_w)
The output is as follows:
Sum of ones RNN from scratchchapter07-rnn/simple_rnn.py:5: RuntimeWarning: overflow encountered in multiply return x * U + s * Wchapter07-rnn/simple_rnn.py:40: RuntimeWarning: invalid value encountered in multiply gU += np.sum(gS * x[:, k - 1])chapter07-rnn/simple_rnn.py:41: RuntimeWarning: invalid value encountered in multiply ...
Read now
Unlock full access