问题描述
txts 是一个字符串列表
log_preds = learn.predict(tuple(txts))
以下是我得到的错误
<ipython-input-21-7b8f82be2aba> in <module>
----> 1 log_preds = learn.predict(tuple(txts))
/opt/conda/lib/python3.7/site-packages/fastai/learner.py in predict(self,item,rm_type_tfms,with_input)
255 def predict(self,rm_type_tfms=None,with_input=False):
256 dl = self.dls.test_dl([item],rm_type_tfms=rm_type_tfms,num_workers=0)
--> 257 inp,preds,_,dec_preds = self.get_preds(dl=dl,with_input=True,with_decoded=True)
258 i = getattr(self.dls,'n_inp',-1)
259 inp = (inp,) if i==1 else tuplify(inp)
/opt/conda/lib/python3.7/site-packages/fastai/learner.py in get_preds(self,ds_idx,dl,with_input,with_decoded,with_loss,act,inner,reorder,cbs,**kwargs)
242 if with_loss: ctx_mgrs.append(self.loss_not_reduced())
243 with ContextManagers(ctx_mgrs):
--> 244 self._do_epoch_validate(dl=dl)
245 if act is None: act = getattr(self.loss_func,'activation',noop)
246 res = cb.all_tensors()
/opt/conda/lib/python3.7/site-packages/fastai/learner.py in _do_epoch_validate(self,dl)
192 if dl is None: dl = self.dls[ds_idx]
193 self.dl = dl
--> 194 with torch.no_grad(): self._with_events(self.all_batches,'validate',CancelValidException)
195
196 def _do_epoch(self):
/opt/conda/lib/python3.7/site-packages/fastai/learner.py in _with_events(self,f,event_type,ex,final)
158
159 def _with_events(self,final=noop):
--> 160 try: self(f'before_{event_type}'); f()
161 except ex: self(f'after_cancel_{event_type}')
162 self(f'after_{event_type}'); final()
/opt/conda/lib/python3.7/site-packages/fastai/learner.py in all_batches(self)
164 def all_batches(self):
165 self.n_iter = len(self.dl)
--> 166 for o in enumerate(self.dl): self.one_batch(*o)
167
168 def _do_one_batch(self):
/opt/conda/lib/python3.7/site-packages/fastai/learner.py in one_batch(self,i,b)
183 b_on_device = tuple( e.to(device=self.dls.device) for e in b if hasattr(e,"to")) if self.dls.device is not None else b
184 self._split(b_on_device)
--> 185 self._with_events(self._do_one_batch,'batch',CancelBatchException)
186
187 def _do_epoch_train(self):
/opt/conda/lib/python3.7/site-packages/fastai/learner.py in _with_events(self,final=noop):
--> 160 try: self(f'before_{event_type}'); f()
161 except ex: self(f'after_cancel_{event_type}')
162 self(f'after_{event_type}'); final()
/opt/conda/lib/python3.7/site-packages/fastai/learner.py in _do_one_batch(self)
167
168 def _do_one_batch(self):
--> 169 self.pred = self.model(*self.xb)
170 self('after_pred')
171 if len(self.yb):
/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self,*input,**kwargs)
725 result = self._slow_forward(*input,**kwargs)
726 else:
--> 727 result = self.forward(*input,**kwargs)
728 for hook in itertools.chain(
729 _global_forward_hooks.values(),TypeError: forward() missing 1 required positional argument: 'x'```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)