Thank you for answering @a_d
I tried this but it gives another error message
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-6-629bcd318457> in <module>
    174         # Forward propagation
    175         v = model(xtrain)
--> 176         outputs = torch.cat((outputs,v.detach()),dim=0)
    177         # Calculate softmax and ross entropy loss
    178     targets = torch.Tensor(targets)

RuntimeError: Expected object of backend CPU but got backend CUDA for sequence element 1 in sequence argument at position #1 'tensors'