I want to use one of  “tourchvision” models in a regression problem where the output is a binary vector of size 64. One option to do this is by replacing the classification layer with a regression layer. As I want to leave the model intact, I am thinking to do it as follows:
...
import torch.nn.functional as F
...
model= get_model('vgg16', num_classes = 64, ....)
...
for batch_idx, (data, target) in enumerate(train_loader):
        data, target = data.to(device), target.to(device)
        optimizer.zero_grad()
        output = model(data)
        output_as_regressor = F.sigmoid(output, dim=1)
        loss += criterion(output_as_regressor, target).item()   # criterion = nn.CrossEntropyLoss()
        ...
...


Should I  use binary_cross_entropy_with_logits  or binary_cross_entropy instead of CrossEntropyLoss?
Haven’t tried it yet and not sure if I am missing something; and, would appreciate hearing any thoughts on it.