Are you sure you are using the same because I don’t get any errors. In your original code,  you are having a line “criterion = nn.BCEWithLogitsLoss().cuda”, you need to change it to “criterion = nn.BCEWithLogitsLoss().cuda()” or “criterion = nn.BCEWithLogitsLoss()”. But I am not sure if you need to pass the criterion to cude since inputs and targets are already there.