Why outputs are replicated after model:forward ondifferent tensors ?

18 views
Skip to first unread message

sri phani krishna karri

unread,
Oct 23, 2016, 9:58:33 AM10/23/16
to torch7
In corresponding code

require 'nn'
torch.manualSeed(27)
model = nn.Sequential()
model:add(nn.SpatialConvolution(1,1,5,5))
gg = model:forward(torch.rand(1,1,16,16))
print(gg)
gg2 = model:forward(torch.ones(1,1,16,16))
print(gg2)
print(gg2-gg)


gg and gg2 are expected to take different values but after 2nd model forward ie gg2 the gg values are also being changed.

Any help?

Vislab

unread,
Oct 23, 2016, 4:23:55 PM10/23/16
to torch7
You are overriding the buffers in this case. Just do gg = model:forward(torch.rand(1,1,16,16)):clone() and gg2 = model:forward(torch.ones(1,1,16,16)):clone() and you'll get different values.

sri phani krishna karri

unread,
Oct 23, 2016, 4:28:11 PM10/23/16
to torch7
Thanks, it worked out
Reply all
Reply to author
Forward
0 new messages