TypeError: cross_entropy_loss(): argument 'input' (position 1) must be Tensor, not tuple

The forward method of your model returns a tuple via:

return output, x    # return x for visualization

which creates the issue in loss = criterion(outputs, labels).
I assume you want to use output to calculate the loss, so use:

        output, x = model(inputs)
        loss = criterion(output, labels)

and it should work.

4 Likes