F.cross_entropy expects a target as a LongTensor containing the class indices.
E.g. for a binary classification use case your output should have the shape [batch_size, nb_classes], while the target should have the shape [batch_size] and contain class indices in the range [0, nb_classes-1].
You could alternatively use nn.BCEWithLogitsLoss or F.binary_cross_entropy_with_logits, which expects a target of the same shape as the model output as a FloatTensor.