you can just implement the criterion yourself, it can get the gradient w.r.t input

  
    
    
    Nn criterions don't compute the gradient w.r.t. targets autograd
  
  
    I am implementing a really basic autoencoder in pytorch. 
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
from torch.autograd import Variable

BATCH_SIZE = 16

criterion_mse = nn.MSELoss().cuda()
x = Variable(torch.FloatTensor( BATCH_SIZE , 10  )  ).cuda()
l = nn.Linear( 10 , 10 ).cuda() 
y = l(x)
loss = criterion_mse( x , y )

But this code gives the following error. 
AssertionError                            Traceback…