The possible reason why input value should be between 0~1

RuntimeError: Assertion `x >= 0. && x <= 1.' failed. input value should be between 0~1, but got -0.234535 at c:\new-builder_3\win-wheel\pytorch\aten\src\thnn\generic/BCECriterion.c:62  

may be because the input of nn.BCELoss() is a decimal of 0 to 1. Instead of a negative number or a number greater than one. It may be because the output value of your activation function is not between 0 and 1. For example, tanh can be solved by changing to sigmoid.

The deeper reasons are yet to be explored.