Hi I m trying to run fastai with https://www.kaggle.com/c/rsna-pneumonia-detection-challenge/data
I m facing problem in while running the kernel.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-20-d053c1db58c5> in <module>()
----> 1 lrf=learn.lr_find(1e-5,100)
/opt/conda/lib/python3.6/site-packages/fastai-0.6-py3.6.egg/fastai/learner.py in lr_find(self, start_lr, end_lr, wds, linear)
255 layer_opt = self.get_layer_opt(start_lr, wds)
256 self.sched = LR_Finder(layer_opt, len(self.data.trn_dl), end_lr, linear=linear)
--> 257 self.fit_gen(self.model, self.data, layer_opt, 1)
258 self.load('tmp')
259
/opt/conda/lib/python3.6/site-packages/fastai-0.6-py3.6.egg/fastai/learner.py in fit_gen(self, model, data, layer_opt, n_cycle, cycle_len, cycle_mult, cycle_save_name, best_save_name, use_clr, metrics, callbacks, use_wd_sched, norm_wds, wds_sched_mult, **kwargs)
159 n_epoch = sum_geom(cycle_len if cycle_len else 1, cycle_mult, n_cycle)
160 return fit(model, data, n_epoch, layer_opt.opt, self.crit,
--> 161 metrics=metrics, callbacks=callbacks, reg_fn=self.reg_fn, clip=self.clip, **kwargs)
162
163 def get_layer_groups(self): return self.models.get_layer_groups()
/opt/conda/lib/python3.6/site-packages/fastai-0.6-py3.6.egg/fastai/model.py in fit(model, data, epochs, opt, crit, metrics, callbacks, stepper, **kwargs)
104 i += 1
105
--> 106 vals = validate(stepper, data.val_dl, metrics)
107 if epoch == 0: print(layout.format(*names))
108 print_stats(epoch, [debias_loss] + vals)
/opt/conda/lib/python3.6/site-packages/fastai-0.6-py3.6.egg/fastai/model.py in validate(stepper, dl, metrics)
126 preds,l = stepper.evaluate(VV(x), VV(y))
127 loss.append(to_np(l))
--> 128 res.append([f(preds.data,y) for f in metrics])
129 return [np.mean(loss)] + list(np.mean(np.stack(res),0))
130
/opt/conda/lib/python3.6/site-packages/fastai-0.6-py3.6.egg/fastai/model.py in <listcomp>(.0)
126 preds,l = stepper.evaluate(VV(x), VV(y))
127 loss.append(to_np(l))
--> 128 res.append([f(preds.data,y) for f in metrics])
129 return [np.mean(loss)] + list(np.mean(np.stack(res),0))
130
/opt/conda/lib/python3.6/site-packages/fastai-0.6-py3.6.egg/fastai/metrics.py in accuracy(preds, targs)
8 def accuracy(preds, targs):
9 preds = torch.max(preds, dim=1)[1]
---> 10 return (preds==targs).float().mean()
11
12 def accuracy_thresh(thresh):
/opt/conda/lib/python3.6/site-packages/torch/tensor.py in __eq__(self, other)
358
359 def __eq__(self, other):
--> 360 return self.eq(other)
361
362 def __ne__(self, other):
TypeError: eq received an invalid combination of arguments - got (torch.cuda.FloatTensor), but expected one of:
* (int value)
didn't match because some of the arguments have invalid types: (!torch.cuda.FloatTensor!)
* (torch.cuda.LongTensor other)
didn't match because some of the arguments have invalid types: (!torch.cuda.FloatTensor!)
I m not sure where I have gone wrong in reading the image with custom open_image
def open_image(loc):
if isinstance(loc, str):
loc = loc + '.dcm'
else: # posix path
loc = loc.as_posix()
img_arr = pydicom.read_file(loc).pixel_array
img_arr = img_arr/img_arr.max()
img_arr = (255*img_arr).clip(0, 255)#.astype(np.int32)
img_arr = Image.fromarray(img_arr).convert('RGB') # model expects 3 channel image
return np.array(img_arr)
It seems to be issue with accuracy method.
pred=
0.0320 0.0000 1.0000 1.0000 1.0000 0.0000
0.0166 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.7434 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0001 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0000 0.0000 1.0000 1.0000 1.0000 0.0000
0.0016 0.0000 1.0000 1.0000 1.0000 0.0000
[torch.cuda.FloatTensor of size 20x6 (GPU 0)]
targs=
0 0 0 1 0 0
0 1 0 0 0 1
1 1 1 1 1 1
0 1 0 0 0 1
1 1 1 1 1 1
0 1 0 0 0 1
1 1 1 1 1 1
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 1 0 0 0 1
0 0 0 1 0 0
0 0 0 1 0 0
0 1 0 0 0 1
0 1 0 0 0 1
0 0 0 1 0 0
0 0 0 1 0 0
1 1 1 1 1 1
0 0 0 1 0 0
1 1 1 1 1 1
[torch.LongTensor of size 20x6]
the accuracy func is,
/opt/conda/lib/python3.6/site-packages/fastai-0.6-py3.6.egg/fastai/metrics.py in accuracy(preds, targs)
8 def accuracy(preds, targs):
9 preds = torch.max(preds, dim=1)[1]
---> 10 return (preds==targs).float().mean()
You can see my kernel at https://www.kaggle.com/nikhilikhar/rsna-with-fastai