I am getting an error "CUDA out of memory" then i add torch.no_grad() function into my code. Is it affect on my accuracy?
for iters in range(args.iterations):
with torch.no_grad():
encoded, encoder_h_1, encoder_h_2, encoder_h_3 = encoder(
res, encoder_h_1, encoder_h_2, encoder_h_3)
with torch.no_grad():
code = binarizer(encoded)
with torch.no_grad():
output, decoder_h_1, decoder_h_2, decoder_h_3, decoder_h_4 = decoder(
code, decoder_h_1, decoder_h_2, decoder_h_3, decoder_h_4)
res = res - output.detach()
codes.append(code.data.cpu().numpy())
torch.cuda.empty_cache()
print('Iter: {:02d}; Loss: {:.06f}'.format(iters, res.data.abs().mean()))