alexobrads:

The target and input values for the BCE are usually between [-1, 3] and occasionally have a large or small value |3000| somewhere in that tensor.


The raised error points most likely to the model output, which might not be in the required range of [0, 1]. Note that also the target should be in the same range, but it seems that you are using values outside of [0, 1]?


Try to add print statements for x_sample and check the min and max values.


Unsure at the moment, but the error is usually raised, if the model output is out of the range.