Based on the error message it seems you are passing an invalid input to your criterion.
This code shows the error:
criterion = nn.BCELoss()
output = torch.randn(10, 1)
target = torch.randint(0, 2, (10, 1)).float()

loss = criterion(output, target)
> RuntimeError: Assertion `x >= 0. && x <= 1.' failed. input value should be between 0~1, but got -0.718591

loss = criterion(torch.sigmoid(output), target) # works