I want to customize my loss function as simple as following.
mb_out is the output from the model forward computation, and it has size (batch_size, 1). They should all reach one in the best case, so I define the following loss function. But seems the loss is not decreasing during training, so I am wondering if this way of defining loss is wrong.

optimizer = optim.Adam(model.parameters(), lr=0.01)
loss = (1 - torch.sum(mb_out, 1)).sum() / float(batch_size)
optimizer.zero_grad()
loss.backward()
optimizer.step()