'Variable' object is not callable

When I use function in network, I got following error:
‘Variable’ object is not callable


def forward(self, x):
     y = x.sum(dim = 1)
     yy = y.view(y.size(0), -1)
     avg = yy.mean(dim = 1)
     mask =, avg(0))

where, x is an NCH*W tensor.

This is because you are trying to call avg by passing in a value of 0. I think you wanted to do an access (i.e. avg[0] on it instead? Even so I don’t think the tensors y and avg[0] wouldn’t match here …?

It only accept float for input, I correct to
mask =, float([0]) ])
Then it works well.