Ok, thanks for the info.
What are you doing with error after returning it?
Are you storing it somewhere?
Also, could you just set your loss to:
error = dice_loss(fake_data.view(-1,1),real_data.view(-1,1)
error.backward()

Do you get any error?