Output size is too small at SpatialAveragePooling.cu:63

I’m trying to run a non-pretrained resnet on my images which are size 160x160. I’m getting the error:

RuntimeError: Given input size: (512x2x2). Calculated output size: (512x-4x-4). Output size is too small at /opt/conda/conda-bld/pytorch_1525909934016/work/aten/src/THCUNN/generic/SpatialAveragePooling.cu:63

Here’s a minimal example for the code I’m running, where the last line produces the error:

from fastai.imports import *
from fastai.conv_learner import *

PATH = '/root/data/cars/'

label_csv = f'{PATH}labels.csv'
n = len(list(open(label_csv)))-1
val_idxs = get_cv_idxs(n)

f_model = resnet18()

def get_data(sz,bs):    
    tfms = tfms_from_model(f_model, sz)
    return ImageClassifierData.from_csv(PATH, 'train', label_csv, tfms=tfms,
                    suffix='.png', val_idxs=val_idxs, bs=bs)

data = get_data(160,16)

bm = BasicModel(f_model.cuda())
learn = ConvLearner(data, bm)
lrf=learn.lr_find()

Is this the correct way to run a non-pretrained resnet on my own data? And how can I correct the error?

EDIT: Also, if I switch f_model to this it doesn’t error out:

from fastai.models.cifar10.senet import SENet18
f_model = SENet18()