muellerzr / Practical-Deep-Learning-for-Coders-2.0

Notebooks for the "A walk with fastai2" Study Group and Lecture Series

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'function' object has no attribute 'sizes'

stuafu opened this issue · comments

commented

I add "num_workers=0" to the dataloaders for avoid error" cuda runtime error (801) : operation not supported at ..\torch/csrc/generic/StorageSharing.cpp:247"

_dls = pascal.dataloaders(path/'train',num_workers=0)

but another error occurred which said "AttributeError: 'function' object has no attribute 'sizes'"!

learn.fit_one_cycle(10, slice(1e-5, 1e-4))

AttributeError Traceback (most recent call last)
in
----> 1 learn.fit_one_cycle(10, slice(1e-5, 1e-4))

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastcore\logargs.py in _f(*args, **kwargs)
54 init_args.update(log)
55 setattr(inst, 'init_args', init_args)
---> 56 return inst if to_return else f(*args, **kwargs)
57 return _f

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\callback\schedule.py in fit_one_cycle(self, n_epoch, lr_max, div, div_final, pct_start, wd, moms, cbs, reset_opt)
111 scheds = {'lr': combined_cos(pct_start, lr_max/div, lr_max, lr_max/div_final),
112 'mom': combined_cos(pct_start, *(self.moms if moms is None else moms))}
--> 113 self.fit(n_epoch, cbs=ParamScheduler(scheds)+L(cbs), reset_opt=reset_opt, wd=wd)
114
115 # Cell

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastcore\logargs.py in _f(*args, **kwargs)
54 init_args.update(log)
55 setattr(inst, 'init_args', init_args)
---> 56 return inst if to_return else f(*args, **kwargs)
57 return _f

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in fit(self, n_epoch, lr, wd, cbs, reset_opt)
205 self.opt.set_hypers(lr=self.lr if lr is None else lr)
206 self.n_epoch = n_epoch
--> 207 self._with_events(self._do_fit, 'fit', CancelFitException, self._end_cleanup)
208
209 def _end_cleanup(self): self.dl,self.xb,self.yb,self.pred,self.loss = None,(None,),(None,),None,None

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in with_events(self, f, event_type, ex, final)
153
154 def with_events(self, f, event_type, ex, final=noop):
--> 155 try: self(f'before
{event_type}') ;f()
156 except ex: self(f'after_cancel
{event_type}')
157 finally: self(f'after_{event_type}') ;final()

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in _do_fit(self)
195 for epoch in range(self.n_epoch):
196 self.epoch=epoch
--> 197 self._with_events(self._do_epoch, 'epoch', CancelEpochException)
198
199 @log_args(but='cbs')

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in with_events(self, f, event_type, ex, final)
153
154 def with_events(self, f, event_type, ex, final=noop):
--> 155 try: self(f'before
{event_type}') ;f()
156 except ex: self(f'after_cancel
{event_type}')
157 finally: self(f'after_{event_type}') ;final()

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in _do_epoch(self)
189
190 def _do_epoch(self):
--> 191 self._do_epoch_train()
192 self._do_epoch_validate()
193

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in _do_epoch_train(self)
181 def _do_epoch_train(self):
182 self.dl = self.dls.train
--> 183 self._with_events(self.all_batches, 'train', CancelTrainException)
184
185 def _do_epoch_validate(self, ds_idx=1, dl=None):

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in with_events(self, f, event_type, ex, final)
153
154 def with_events(self, f, event_type, ex, final=noop):
--> 155 try: self(f'before
{event_type}') ;f()
156 except ex: self(f'after_cancel
{event_type}')
157 finally: self(f'after_{event_type}') ;final()

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in all_batches(self)
159 def all_batches(self):
160 self.n_iter = len(self.dl)
--> 161 for o in enumerate(self.dl): self.one_batch(*o)
162
163 def _do_one_batch(self):

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in one_batch(self, i, b)
177 self.iter = i
178 self._split(b)
--> 179 self._with_events(self._do_one_batch, 'batch', CancelBatchException)
180
181 def _do_epoch_train(self):

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in with_events(self, f, event_type, ex, final)
153
154 def with_events(self, f, event_type, ex, final=noop):
--> 155 try: self(f'before
{event_type}') ;f()
156 except ex: self(f'after_cancel
{event_type}')
157 finally: self(f'after_{event_type}') ;final()

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\fastai2\learner.py in _do_one_batch(self)
164 self.pred = self.model(*self.xb)
165 self('after_pred')
--> 166 if len(self.yb): self.loss = self.loss_func(self.pred, *self.yb)
167 self('after_loss')
168 if not self.training or not len(self.yb): return

D:\Users\fanyo\Anaconda3\envs\fastai2\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
720 result = self._slow_forward(*input, **kwargs)
721 else:
--> 722 result = self.forward(*input, **kwargs)
723 for hook in itertools.chain(
724 _global_forward_hooks.values(),

D:\fastai2.0\nbs\files\Practical-Deep-Learning-for-Coders-2.0-master\Computer Vision\imports\metrics.py in forward(self, output, bbox_tgts, clas_tgts)
147 def forward(self, output, bbox_tgts, clas_tgts):
148 bbox_preds, clas_preds = output
--> 149 sizes = self.model.sizes
150 if self._change_anchors(sizes): self._create_anchors(sizes, clas_preds.device)
151 n_classes = clas_preds.size(2)

AttributeError: 'function' object has no attribute 'sizes'