loss_fn = reg_BCELoss(dim=2)
loss = 0
for i_batch, (samples, labels) in enumerate(TrainDL):
loss_batch = loss_fn(labels_pred, labels)
loss += loss_batch.item()
Now I’d like to set weights inside my training loop but apparently only the constructor can set weights which means, I’d have to create the loss function object inside the loop. Which means, I’d create thousands of objects.
So, what do I do? Do I try to do something stupid?
What do you mean by class? In any case: I don’t want to pass the weights to the constructor but to the forward function. See argument in my other post. The reason for that is simple: I don’t want to go through GB and GB of data and pass several hundred of megabytes of information to one argument. Just seems wrong.