Understanding code - error Expected more than 1 value per channel when training

It has no relationship with the batch size, I modified it several times and nothing changed.

But I figured out that if this lines of code give me that error "ValueError: Expected more than 1 value per channel when training, got input size [1, 4096]"

data = ImageClassifierData.from_paths(PATH, tfms=tfms, bs=bs)
learn = ConvLearner.pretrained(arch, data)

x,y = next(iter(data.val_dl))
x,y = x[None,0], y[None,0]
m  = learn.models.model
py = m(Variable(x.cuda())); py

as soon as I call learn.predict I have no error anymore

data = ImageClassifierData.from_paths(PATH, tfms=tfms, bs=bs)
learn = ConvLearner.pretrained(arch, data)

learn.predict()

x,y = next(iter(data.val_dl))
x,y = x[None,0], y[None,0]
m  = learn.models.model
py = m(Variable(x.cuda())); py

Variable containing:
-0.9635 -2.2739 -0.6625
[torch.cuda.FloatTensor of size 1x3 (GPU 0)]

2 Likes