Cannot get the value of hidden weights of RNN
I declare my RNN as
self.rnn = torch.nn.RNN(input_size=encoding_dim, hidden_size=1, num_layers=1, nonlinearity='relu')

Later
self.rnn.all_weights
# [[Parameter containing:
tensor([[-0.8099, -0.9543,  0.1117,  0.6221,  0.5034, -0.6766, -0.3360, -0.1700,
         -0.9361, -0.3428]], requires_grad=True), Parameter containing:
tensor([[-0.1929]], requires_grad=True), Parameter containing:
tensor([0.7881], requires_grad=True), Parameter containing:
tensor([0.4320], requires_grad=True)]]

self.rnn.all_weights[0][0][0].values
# {RuntimeError}Could not run 'aten::values' with arguments from the 'CPU' backend. 'aten::values' is only available for these backends: [SparseCPU, Autograd, Profiler, Tracer].

Clearly I see the value of the weights, but cannot access to it. Documentation says I need to specify requires_grad=True, but that does not work.
Is there a more elegant and usable way than self.rnn.all_weights[0][0][0]?

Use torch.nn.Module.named_parameters or torch.nn.Module.parameters.
&gt;&gt;&gt; import torch.nn as nn
&gt;&gt;&gt; model = nn.RNN(input_size=encoding_dim, hidden_size=1, num_layers=1, nonlinearity='relu')
&gt;&gt;&gt; weights = []
&gt;&gt;&gt; for name, parameter in model.named_parameters():
...     weights.append({name: parameter[0]})
...
&gt;&gt;&gt; just_weights = []
&gt;&gt;&gt; for parameter in model.parameters():
...     just_weights.append(parameter[0])
...

