Doubts in Charecter level RNN tutorial

Hi I am going through PyTorch tutorial at

http://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.html#training.

Inside the train() function the network parameters are updated with gradients using the below line.

p.data.add_(-learning_rate, p.grad.data)

the add function I saw in the source code accepts only one argument. How does the function accepts 2 arguments and multiplies the learning rate with gradients and add that to the tensor data.

1 Like

See the second signature of torch.add (there are two):

http://pytorch.org/docs/torch.html#torch.add

it does: y = y + alpha * x

1 Like