Yes, that's exactly right! For multi-label binary classification, you would:
- Apply BCE loss to each output neuron independently
- Sum these individual losses to get the total loss for backpropagation
This approach works because each binary classification is treated as a separate problem, even though they're being solved in parallel by the same network.
In code, it would look something like this:
# PyTorch example
criterion = nn.BCEWithLogitsLoss(reduction='none') # Keep individual losses
outputs = model(inputs) # Shape: [batch_size, num_classes]
targets = labels # Shape: [batch_size, num_classes] with 0s and 1s
# Individual losses for each classification task
individual_losses = criterion(outputs, targets) # Shape: [batch_size, num_classes]
# For curriculum learning, create a mask for active tasks
if using_curriculum:
active_tasks = min(4 + epoch//curriculum_step, total_tasks)
mask = torch.zeros_like(individual_losses)
mask[:, :active_tasks] = 1.0
individual_losses = individual_losses * mask
# Sum losses for backpropagation
total_loss = individual_losses.sum()
# Or mean if you prefer: total_loss = individual_losses.sum() / active_tasks
Most deep learning frameworks will handle this summation automatically if you use the default reduction='mean' or reduction='sum' in the loss function, but the explicit approach above gives you more control for curriculum learning.