hi ptrblck,
The code is as follows:
def loss_fn(out2, data_loss, z_loc, z_scale):
       BCE = F.cross_entropy(data_loss,out2, size_average=True,reduction ='mean')

elsewhere in the code:
        data = data.cuda()
        z_loc, z_scale = model.Encoder(data)
        out = model.Decoder(z)
        data_loss=data
        data_loss=data_loss.squeeze(1)
        out2=out.squeeze(1)

I am using the squeeze functions because i had an error about a size 3 tensor been used from the output of my network, when cross entropy only needs a size 2 tensor. I have tried it with and wthout the squeeze on the input data and it dosen’t complain…
chaslie