Hello ptrblck sir,
I’m facing an issue with view, could you please help me with it below is the error:
RuntimeError                              Traceback (most recent call last)
 in 
----> 1 learn.fit_one_cycle(2)
~\Anaconda3\envs\fastai_v1\lib\site-packages\fastai\train.py in fit_one_cycle(learn, cyc_len, max_lr, moms, div_factor, pct_start, final_div, wd, callbacks, tot_epochs, start_epoch)
21     callbacks.append(OneCycleScheduler(learn, max_lr, moms=moms, div_factor=div_factor, pct_start=pct_start,
22                                        final_div=final_div, tot_epochs=tot_epochs, start_epoch=start_epoch))
—> 23     learn.fit(cyc_len, max_lr, wd=wd, callbacks=callbacks)
24
25 def fit_fc(learn:Learner, tot_epochs:int=1, lr:float=defaults.lr,  moms:Tuple[float,float]=(0.95,0.85), start_pct:float=0.72,
~\Anaconda3\envs\fastai_v1\lib\site-packages\fastai\basic_train.py in fit(self, epochs, lr, wd, callbacks)
198         else: self.opt.lr,self.opt.wd = lr,wd
199         callbacks = [cb(self) for cb in self.callback_fns + listify(defaults.extra_callback_fns)] + listify(callbacks)
–> 200         fit(epochs, self, metrics=self.metrics, callbacks=self.callbacks+callbacks)
201
202     def create_opt(self, lr:Floats, wd:Floats=0.)->None:
~\Anaconda3\envs\fastai_v1\lib\site-packages\fastai\basic_train.py in fit(epochs, learn, callbacks, metrics)
99             for xb,yb in progress_bar(learn.data.train_dl, parent=pbar):
100                 xb, yb = cb_handler.on_batch_begin(xb, yb)
–> 101                 loss = loss_batch(learn.model, xb, yb, learn.loss_func, learn.opt, cb_handler)
102                 if cb_handler.on_batch_end(loss): break
103
~\Anaconda3\envs\fastai_v1\lib\site-packages\fastai\basic_train.py in loss_batch(model, xb, yb, loss_func, opt, cb_handler)
24     if not is_listy(xb): xb = [xb]
25     if not is_listy(yb): yb = [yb]
—> 26     out = model(*xb)
27     out = cb_handler.on_loss_begin(out)
28
~\Anaconda3\envs\fastai_v1\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
548             result = self._slow_forward(*input, **kwargs)
549         else:
–> 550             result = self.forward(*input, **kwargs)
551         for hook in self._forward_hooks.values():
552             hook_result = hook(self, input, result)
 in forward(self, x)
33     def forward(self, x):
34         x = self.seq1(x)
—> 35         x = x.view(-1, 12612616)
36         x = self.seq2(x)
37         x = self.seq3(x)
RuntimeError: shape ‘[-1, 254016]’ is invalid for input of size 1548800
and this is the code
class BuildingSegmenterNet(nn.Module):
def init(self):
super(BuildingSegmenterNet, self).init()
self.seq1 = nn.Sequential(
nn.Conv2d(3, 16, (5,5)),
nn.MaxPool2d((2,2))
)
self.seq2 = nn.Sequential(
nn.Linear((12612616), 512),
nn.ReLU()
)
self.dropout1 = nn.Dropout(0.33)
self.seq3 = nn.Sequential(
nn.Linear(512, 128),
nn.ReLU()
)
self.seq4 = nn.Sequential(
nn.Linear(128, 128),
nn.ReLU()
)
self.seq5 = nn.Sequential(
nn.Linear(128, 512),
nn.ReLU()
)
self.seq6 = nn.Sequential(
nn.Linear(512, 256256),
nn.ReLU()
)
self.seq7 = nn.Sequential(
nn.Conv2d(1, 1, (3,3), padding = 1),
nn.Sigmoid()
)
def forward(self, x):
x = self.seq1(x)
x = x.view(-1, 126126*16)
x = self.seq2(x)
x = self.seq3(x)
x = self.dropout1(x)
x = self.seq4(x)
x = self.seq5(x)
x = self.seq6(x)
x = x.view(x.size(0), -1)
x = self.seq7(x)
return x
My image is size is 200*200 RGB and i have kept the batch size as 8
Could you please help me to resolve this error.
thanking you in advance
Regareds,
Rahul Ramchandra Uppari.