22.02.2024 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Output

OrderedDict([('weight_ih', tensor([[-0.0930, 0.0497],

[ 0.4670, -0.5319],

[-0.6656, 0.0699],

[-0.1662, 0.0654],

[-0.0449, -0.6828],

[-0.6769, -0.1889],

[-0.4167, -0.4352],

[-0.2060, -0.3989]])),

('weight_hh', tensor([[-0.7070, -0.5083],

[ 0.1418, 0.0930],

[-0.5729, -0.5700],

[-0.1818, -0.6691],

[-0.4316, 0.4019],

[ 0.1222, -0.4647],

[-0.5578, 0.4493],

[-0.6800, 0.4422]])),

('bias_ih',

tensor([-0.3559, -0.0279, 0.6553, 0.2918, 0.4007,

0.3262, -0.0778, -0.3002])),

('bias_hh',

tensor([-0.3991, -0.3200, 0.3483, -0.2604, -0.1582,

0.5558, 0.5761, -0.3919]))])

Guess what? We get the same weird shapes again, but this time there are four

components instead of three. You already know the drill: Split the weights and

biases using split() and create linear layers using the linear_layers() function.

Long Short-Term Memory (LSTM) | 645

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

Saved successfully!

Ooh no, something went wrong!