How to create binary image classification learner?

On using the ImageDataBunch and cnn_learner on a binary label type task, it creates a model with 2 output activations. Is there a way to create a learner which has a single output activation.
In my case:
data = ImageDataBunch.from_df(
path=’./dataset/combined’,
df=conv_df,
valid_pct=0.2,
ds_tfms=tfms,
fn_col=‘Image_paths’,
label_col=‘condition’,
size=256,
bs=64
).normalize(imagenet_stats)
model = models.resnet34
learn = cnn_learner(data, model, metrics=[accuracy])

Then learn.model has the final layer as - (8): Linear(in_features=512, out_features=2, bias=True).
I want it to be of form - (8): Linear(in_features=512, out_features=1, bias=True).

Thank you!

1 Like