Torch.add() error

When I am using torch.add(), I have encountered the following error

inputs = torch.add(inputs, -0.02, noise)
TypeError: add() takes exactly 2 arguments (3 given)

The error should be quite self explanatory, you’ve given torch.add too many arguments.

I have the same problem - and while it seems inded self-explanatory, it contradicts the documentation in: http://pytorch.org/docs/torch.html

Which says:
torch.add(input, value, out=None)
Adds the scalar value to each element of the input input and returns a new resulting tensor.

So - I will be using torch.mul, but the question is in place, and someone has to either implement the correct function or fix the documentation

I’ve tried to reproduce Shiyu’s error, but I cant.
Can one of you give me a repro:

In [1]: import torch

In [2]: a=torch.randn(10)

In [3]: torch.add(a, 0.1, a)
Out[3]:

 0.9079
 1.1069
-1.5801
-0.3657
-0.6019
-0.5571
 0.5797
 0.2054
-0.9112
-0.7749
[torch.FloatTensor of size 10]

I am not near pc now, but thing it - it worked when I used python in shell
and did the problem when I ran it from a file with some importa and so on.

Will be able to send details tomorrow.

Now it is working, but doesn’t do anything:

The code I wrote in a file:

import torch

q =torch.randn(10)
print "1 ",q
torch.add(q, 0.1, q)
print "2 ",q
exit()

The output I get:
1
1.6000
-0.5714
-2.1857
0.9774
2.3266
-2.2662
-1.2868
-0.7741
-0.3532
-0.0593
[torch.FloatTensor of size 10]

2
1.6000
-0.5714
-2.1857
0.9774
2.3266
-2.2662
-1.2868
-0.7741
-0.3532
-0.0593
[torch.FloatTensor of size 10]

you did a basic mistake. you should do: q = torch.add(q, 0.1, q)

OK, :embarrassed:, i was in a hurry - looks like it’s working now. Thanks.