Oualid:

Do you mean that there is another implementation of Alexnet with the name AlexnetTS.forward?


No, I don’t think so.
But, I’d first check



 Oualid:

loss = nn.CrossEntropyLoss()(model(X + delta), y)


as model(X + delta) might return a tuple.

x = torch.randn(4, 1)
y = torch.randn(4, 1)

nn.CrossEntropyLoss()((x, x), y)

The above snippet raises an error as follows.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-5f2ffb16d2b6> in <module>()
      2 y = torch.randn(4, 1)
      3 
----> 4 nn.CrossEntropyLoss()((x, x), y)

3 frames
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py in log_softmax(input, dim, _stacklevel, dtype)
   1670         dim = _get_softmax_dim("log_softmax", input.dim(), _stacklevel)
   1671     if dtype is None:
-> 1672         ret = input.log_softmax(dim)
   1673     else:
   1674         ret = input.log_softmax(dim, dtype=dtype)

AttributeError: 'tuple' object has no attribute 'log_softmax'