so I have some annotated images that I want to use to train a binary image classifier but I have been having issues creating the dataset and actually getting a test model to train. Each image is either of a certain class or not so I want to set up a binary classification dataset/model using PyTorch. I had some questions:

  1. should labels be float or long?

  2. what shape should my labels be?

  3. I am using a resnet18 class from torchvision model, should my final softmax layer have one or two outputs?

  4. what shapes should my target be, during training, if my batch size is 200?

  5. what shape should my outputs be?

Thanks in advance

Quote Delete


1 Answer 1


According to your questions:

  1. Labels should be long and advised.
  2. [num_samples, ]
  3. It should have two outputs.
  4. If your batch_size=200 then target somehow similar to this: [0, 1, 0, 1, 1, 0, ....1]
  5. 3rd ^

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.