(1.0.54) Still throws: ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 4096])

Although drop_last == True in data loader, I can’t get it running. I pretrained a resnet152 model on 1024 images, with bs=8, now, when moving to larger images (2048x2048) I need to reduce the batch size and this problem appears.

print(data.train_dl.dl.drop_last)
True

Any problems with the code below? It’s so annoying :confused:

My code:

data = ImageDataBunch.from_df(path_to_images, 
                              df,
                              ds_tfms=get_transforms(),
                              valid_pct=0.2, 
                              bs=2,
                              size=2048).normalize(imagenet_stats)

print(data.train_ds)

    LabelList (13215 items)
    x: ImageList
    Image (3, 2048, 2048),Image (3, 2048, 2048),Image (3, 2048, 2048),Image (3, 2048, 2048),Image (3, 2048, 2048)
    y: CategoryList
    ab,ab,ab,ab,ab
    Path: /mnt/sdf/training_data

data.valid_ds

LabelList (3303 items)
x: ImageList
Image (3, 2048, 2048),Image (3, 2048, 2048),Image (3, 2048, 2048),Image (3, 2048, 2048),Image (3, 2048, 2048)
y: CategoryList
ab,veh,veh,veh,veh
Path: /mnt/sdf/training_data

learn = cnn_learner(data, models.resnet152, metrics=accuracy,  bn_final=True, ps=0.5).load('resnet152_1024')
learn.to_fp16()
learn.model = torch.nn.DataParallel(learn.model)


learn.lr_find(start_lr=1e-10)
learn.recorder.plot()

/mnt/sdf/py_torch/lib/python3.6/site-packages/torch/nn/functional.py in batch_norm(input, running_mean, running_var, weight, bias, training, momentum, eps)
1691 size_prods *= size[i + 2]
1692 if size_prods == 1:
-> 1693 raise ValueError(‘Expected more than 1 value per channel when training, got input size {}’.format(size))
1694
1695 return torch.batch_norm(

ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 4096])