Thanks for your fast reply. I am running it on a GPU run time.
Full trace is as below
TypeError Traceback (most recent call last)
in ()
1 lr = 1e-5 # trying a v conservative LR quickly
----> 2 learn.fit_one_cycle(1, slice(lr))
15 frames
/usr/local/lib/python3.6/dist-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,
/usr/local/lib/python3.6/dist-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:
/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in fit(epochs, learn, callbacks, metrics)
104 if not cb_handler.skip_validate and not learn.data.empty_val:
105 val_loss = validate(learn.model, learn.data.valid_dl, loss_func=learn.loss_func,
–> 106 cb_handler=cb_handler, pbar=pbar)
107 else: val_loss=None
108 if cb_handler.on_epoch_end(val_loss): break
/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in validate(model, dl, loss_func, cb_handler, pbar, average, n_batch)
61 if not is_listy(yb): yb = [yb]
62 nums.append(first_el(yb).shape[0])
—> 63 if cb_handler and cb_handler.on_batch_end(val_losses[-1]): break
64 if n_batch and (len(nums)>=n_batch): break
65 nums = np.array(nums, dtype=np.float32)
/usr/local/lib/python3.6/dist-packages/fastai/callback.py in on_batch_end(self, loss)
306 “Handle end of processing one batch with loss
.”
307 self.state_dict[‘last_loss’] = loss
–> 308 self(‘batch_end’, call_mets = not self.state_dict[‘train’])
309 if self.state_dict[‘train’]:
310 self.state_dict[‘iteration’] += 1
/usr/local/lib/python3.6/dist-packages/fastai/callback.py in call(self, cb_name, call_mets, **kwargs)
248 “Call through to all of the CallbakHandler
functions.”
249 if call_mets:
–> 250 for met in self.metrics: self._call_and_update(met, cb_name, **kwargs)
251 for cb in self.callbacks: self._call_and_update(cb, cb_name, **kwargs)
252
/usr/local/lib/python3.6/dist-packages/fastai/callback.py in _call_and_update(self, cb, cb_name, **kwargs)
239 def call_and_update(self, cb, cb_name, **kwargs)->None:
240 “Call cb_name
on cb
and update the inner state.”
–> 241 new = ifnone(getattr(cb, f’on{cb_name}’)(**self.state_dict, **kwargs), dict())
242 for k,v in new.items():
243 if k not in self.state_dict:
/usr/local/lib/python3.6/dist-packages/fastai/callback.py in on_batch_end(self, last_output, last_target, **kwargs)
342 if not is_listy(last_target): last_target=[last_target]
343 self.count += first_el(last_target).size(0)
–> 344 val = self.func(last_output, *last_target)
345 if self.world:
346 val = val.clone()
in jq(y_pred, y_true, thresh)
6 for i in range(len(y_true)):
7 binary_preds = (y_pred[i][0].flatten()>thresh).int()
----> 8 score = sklearn.metrics.jaccard_score(y_true[i].flatten(), binary_preds, average=‘micro’)
9 scores.append(score)
10 return torch.tensor(sum(scores)/len(scores))
/usr/local/lib/python3.6/dist-packages/sklearn/metrics/_classification.py in jaccard_score(y_true, y_pred, labels, pos_label, average, sample_weight)
791 “”"
792 labels = _check_set_wise_labels(y_true, y_pred, average, labels,
–> 793 pos_label)
794 samplewise = average == ‘samples’
795 MCM = multilabel_confusion_matrix(y_true, y_pred,
/usr/local/lib/python3.6/dist-packages/sklearn/metrics/_classification.py in _check_set_wise_labels(y_true, y_pred, average, labels, pos_label)
1299 str(average_options))
1300
-> 1301 y_type, y_true, y_pred = _check_targets(y_true, y_pred)
1302 present_labels = unique_labels(y_true, y_pred)
1303 if average == ‘binary’:
/usr/local/lib/python3.6/dist-packages/sklearn/metrics/_classification.py in _check_targets(y_true, y_pred)
79 “”"
80 check_consistent_length(y_true, y_pred)
—> 81 type_true = type_of_target(y_true)
82 type_pred = type_of_target(y_pred)
83
/usr/local/lib/python3.6/dist-packages/sklearn/utils/multiclass.py in type_of_target(y)
245 raise ValueError(“y cannot be class ‘SparseSeries’ or ‘SparseArray’”)
246
–> 247 if is_multilabel(y):
248 return ‘multilabel-indicator’
249
/usr/local/lib/python3.6/dist-packages/sklearn/utils/multiclass.py in is_multilabel(y)
136 “”"
137 if hasattr(y, ‘array’) or isinstance(y, Sequence):
–> 138 y = np.asarray(y)
139 if not (hasattr(y, “shape”) and y.ndim == 2 and y.shape[1] > 1):
140 return False
/usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
83
84 “”"
—> 85 return array(a, dtype, copy=False, order=order)
86
87
/usr/local/lib/python3.6/dist-packages/torch/tensor.py in array(self, dtype)
484 def array(self, dtype=None):
485 if dtype is None:
–> 486 return self.cpu().numpy()
487 else:
488 return self.cpu().numpy().astype(dtype, copy=False)
TypeError: can’t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.