22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Now we’re talking! The last hidden state, (-0.5297, 0.3551), is the representation of

the full sequence.

Figure 8.9 depicts what the loop above looks like at the neuron level. In it, you can

easily see what I call "the journey of a hidden state": It is transformed, translated

(adding the input), and activated many times over. Moreover, you can also see that

the data points are independently transformed—the model will learn the best way

to transform them. We’ll get back to this after training a model.

At this point, you may be thinking:

"Looping over the data points in a sequence?! That looks like a lot of

work!"

And you’re absolutely right! Instead of an RNN cell, we can use a full-fledged…

RNN Layer

The nn.RNN layer takes care of the hidden state handling for us, no matter how long

the input sequence is. This is the layer we’ll actually be using in the model. We’ve

been through the inner workings of its cells, but the full-fledged RNN offers many

more options (stacked and / or bidirectional layers, for instance) and one tricky

thing regarding the shapes of inputs and outputs (yes, shapes are a kinda recurrent

problem—pun intended!).

Recurrent Neural Networks (RNNs) | 601

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!