Trying non-resnet model for Pets dataset

I was trying to experiment with using inception-v3 instead of resnet for pets dataset. This is what I did:

  1. In the fastai/vision/models/init.py added from torchvision.models import Inception,inception_v3
    2.change the leaener with inception v3 learn = create_cnn(data,models.inception_v3,pretrained=True,metrics=error_rate).This downloads the weight from the url .so far it looks good
    3.Now when I try to run a single epoch using learn.fit_one_cycle(1) I get a shape mismatch error in the forward of model as below

RuntimeError Traceback (most recent call last)
in ()
----> 1 learn.fit_one_cycle(1)

~/.anaconda3/lib/python3.7/site-packages/fastai/train.py in fit_one_cycle(learn, cyc_len, max_lr, moms, div_factor, pct_start, wd, callbacks, **kwargs)
17 callbacks.append(OneCycleScheduler(learn, max_lr, moms=moms, div_factor=div_factor,
18 pct_start=pct_start, **kwargs))
—> 19 learn.fit(cyc_len, max_lr, wd=wd, callbacks=callbacks)
20
21 def lr_find(learn:Learner, start_lr:Floats=1e-7, end_lr:Floats=10, num_it:int=100, stop_div:bool=True, **kwargs:Any):

~/.anaconda3/lib/python3.7/site-packages/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
159 callbacks = [cb(self) for cb in self.callback_fns] + listify(callbacks)
160 fit(epochs, self.model, self.loss_func, opt=self.opt, data=self.data, metrics=self.metrics,
–> 161 callbacks=self.callbacks+callbacks)
162
163 def create_opt(self, lr:Floats, wd:Floats=0.)->None:

~/.anaconda3/lib/python3.7/site-packages/fastai/basic_train.py in fit(epochs, model, loss_func, opt, data, callbacks, metrics)
91 except Exception as e:
92 exception = e
—> 93 raise e
94 finally: cb_handler.on_train_end(exception)
95

~/.anaconda3/lib/python3.7/site-packages/fastai/basic_train.py in fit(epochs, model, loss_func, opt, data, callbacks, metrics)
81 for xb,yb in progress_bar(data.train_dl, parent=pbar):
82 xb, yb = cb_handler.on_batch_begin(xb, yb)
—> 83 loss = loss_batch(model, xb, yb, loss_func, opt, cb_handler)
84 if cb_handler.on_batch_end(loss): break
85

~/.anaconda3/lib/python3.7/site-packages/fastai/basic_train.py in loss_batch(model, xb, yb, loss_func, opt, cb_handler)
16 if not is_listy(xb): xb = [xb]
17 if not is_listy(yb): yb = [yb]
—> 18 out = model(*xb)
19 out = cb_handler.on_loss_begin(out)
20

~/.anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
475 result = self._slow_forward(*input, **kwargs)
476 else:
–> 477 result = self.forward(*input, **kwargs)
478 for hook in self._forward_hooks.values():
479 hook_result = hook(self, input, result)

~/.anaconda3/lib/python3.7/site-packages/torch/nn/modules/container.py in forward(self, input)
90 def forward(self, input):
91 for module in self._modules.values():
—> 92 input = module(input)
93 return input
94

~/.anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
475 result = self._slow_forward(*input, **kwargs)
476 else:
–> 477 result = self.forward(*input, **kwargs)
478 for hook in self._forward_hooks.values():
479 hook_result = hook(self, input, result)

~/.anaconda3/lib/python3.7/site-packages/torch/nn/modules/container.py in forward(self, input)
90 def forward(self, input):
91 for module in self._modules.values():
—> 92 input = module(input)
93 return input
94

~/.anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
475 result = self._slow_forward(*input, **kwargs)
476 else:
–> 477 result = self.forward(*input, **kwargs)
478 for hook in self._forward_hooks.values():
479 hook_result = hook(self, input, result)

~/.anaconda3/lib/python3.7/site-packages/torchvision/models/inception.py in forward(self, x)
310 x = x.view(x.size(0), -1)
311 # 768
–> 312 x = self.fc(x)
313 # 1000
314 return x

~/.anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
475 result = self._slow_forward(*input, **kwargs)
476 else:
–> 477 result = self.forward(*input, **kwargs)
478 for hook in self._forward_hooks.values():
479 hook_result = hook(self, input, result)

~/.anaconda3/lib/python3.7/site-packages/torch/nn/modules/linear.py in forward(self, input)
61
62 def forward(self, input):
—> 63 return F.linear(input, self.weight, self.bias)
64
65 def extra_repr(self):

~/.anaconda3/lib/python3.7/site-packages/torch/nn/functional.py in linear(input, weight, bias)
1136 if input.dim() == 2 and bias is not None:
1137 # fused op is marginally faster
-> 1138 return torch.addmm(bias, input, weight.t())
1139
1140 output = input.matmul(weight.t())

RuntimeError: size mismatch, m1: [8 x 19200], m2: [768 x 1000] at /opt/conda/conda-bld/pytorch-nightly_1540036376816/work/aten/src/THC/generic/THCTensorMathBlas.cu:266

I further used %debug to check the shape of bias, input, and weight where we are getting the shape mismatch error and:

bias.shape torch.Size([1000])
input.shape torch.Size([8, 19200])
weight.shape torch.Size([1000, 768])

I don’t know what I am missing here ? Is there something specific about non-resnet models we need to take into account while using fastai as the front end? Edit-Is this because Inception has two outputs Aux and end output and the learner is changing the shape for end fully connected and not the auxiliary one?I need to dig deeper.