Skip to content

Commit 793d93a

Browse files
committed
Sanity-check the weights
1 parent c920f11 commit 793d93a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

_posts/2019-10-11-a-basic-rnn.markdown

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,24 @@ Tracked 1×1 Array{Float32,2}:
271271
3.0166523f
272272
{% endhighlight %}
273273

274+
We also want to sanity-check our results by looking directly at the parameters. An RNN of this type should have 3 parameters: a weight for the input, a weight for the input from the previous timestep, and a bias. When we check the parameters of our model, we would expect that the two weights for the input (current and previous) are both 1 and that the bias is 0, just like in an adder. Thankfully, that's exactly what we have!
275+
276+
{% highlight julia %}
277+
julia> simple_rnn.cell.Wi
278+
Tracked 1×1 Array{Float32,2}:
279+
1.0012805f0
280+
281+
julia> simple_rnn.cell.Wh
282+
Tracked 1×1 Array{Float32,2}:
283+
0.9984506f0
284+
285+
julia> simple_rnn.cell.b
286+
Tracked 1-element Array{Float32,1}:
287+
1.6119986f-5
288+
{% endhighlight %}
289+
290+
Yay! We made an adder!
291+
274292
# Incorrect Models
275293

276294
Above, I alluded to model selection as being an important part of machine learning. I am constantly reminded of this in my day job (I do computer vision, software, machine learning, data analysis for robotics) and was reminded of it again here. Before I looked at the Flux definition of an RNN, I didn't realize that the default activation function was `tanh`, which clips the function to the range `[-1, 1]`. Running the same training / evaluation code above but with this model:

0 commit comments

Comments
 (0)