Fit_one_cycle error on epoch end when using MatthewsCorreff [Solved]

Hello :slight_smile:

Edit :
If only I could read ! : " The following metrics are classes, don’t forget to instantiate them when you pass them to a Learner ."

I tried to train my binary classification model with the metric error_rate showing and it works.
But when I wanted to see the MatthewsCorreff :

learn = create_cnn(data, models.resnet34, metrics=MatthewsCorreff)

I got this error message in the first epoch :

epoch train_loss valid_loss MatthewsCorreff
Interrupted


TypeError Traceback (most recent call last)

in ()
----> 1 learn.fit_one_cycle(5)

/usr/local/lib/python3.6/dist-packages/fastai/train.py in fit_one_cycle(learn, cyc_len, max_lr, moms, div_factor, pct_start, wd, callbacks, **kwargs)
20 callbacks.append(OneCycleScheduler(learn, max_lr, moms=moms, div_factor=div_factor,
21 pct_start=pct_start, **kwargs))
—> 22 learn.fit(cyc_len, max_lr, wd=wd, callbacks=callbacks)
23
24 def lr_find(learn:Learner, start_lr:Floats=1e-7, end_lr:Floats=10, num_it:int=100, stop_div:bool=True, **kwargs:Any):

/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
176 callbacks = [cb(self) for cb in self.callback_fns] + listify(callbacks)
177 fit(epochs, self.model, self.loss_func, opt=self.opt, data=self.data, metrics=self.metrics,
–> 178 callbacks=self.callbacks+callbacks)
179
180 def create_opt(self, lr:Floats, wd:Floats=0.)->None:

/usr/local/lib/python3.6/dist-packages/fastai/utils/mem.py in wrapper(*args, **kwargs)
83
84 try:
—> 85 return func(*args, **kwargs)
86 except Exception as e:
87 if “CUDA out of memory” in str(e) or tb_clear_frames==“1”:

/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in fit(epochs, model, loss_func, opt, data, callbacks, metrics)
98 except Exception as e:
99 exception = e
–> 100 raise e
101 finally: cb_handler.on_train_end(exception)
102

/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in fit(epochs, model, loss_func, opt, data, callbacks, metrics)
93 if not data.empty_val:
94 val_loss = validate(model, data.valid_dl, loss_func=loss_func,
—> 95 cb_handler=cb_handler, pbar=pbar)
96 else: val_loss=None
97 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)
55 if not is_listy(yb): yb = [yb]
56 nums.append(yb[0].shape[0])
—> 57 if cb_handler and cb_handler.on_batch_end(val_losses[-1]): break
58 if n_batch and (len(nums)>=n_batch): break
59 nums = np.array(nums, dtype=np.float32)

/usr/local/lib/python3.6/dist-packages/fastai/callback.py in on_batch_end(self, loss)
256 “Handle end of processing one batch with loss.”
257 self.state_dict[‘last_loss’] = loss
–> 258 stop = np.any(self(‘batch_end’, not self.state_dict[‘train’]))
259 if self.state_dict[‘train’]:
260 self.state_dict[‘iteration’] += 1

/usr/local/lib/python3.6/dist-packages/fastai/callback.py in call(self, cb_name, call_mets, **kwargs)
197 def call(self, cb_name, call_mets=True, **kwargs)->None:
198 “Call through to all of the CallbakHandler functions.”
–> 199 if call_mets: [getattr(met, f’on_{cb_name}’)(**self.state_dict, **kwargs) for met in self.metrics]
200 return [getattr(cb, f’on_{cb_name}’)(**self.state_dict, **kwargs) for cb in self.callbacks]
201

/usr/local/lib/python3.6/dist-packages/fastai/callback.py in (.0)
197 def call(self, cb_name, call_mets=True, **kwargs)->None:
198 “Call through to all of the CallbakHandler functions.”
–> 199 if call_mets: [getattr(met, f’on_{cb_name}’)(**self.state_dict, **kwargs) for met in self.metrics]
200 return [getattr(cb, f’on_{cb_name}’)(**self.state_dict, **kwargs) for cb in self.callbacks]
201

/usr/local/lib/python3.6/dist-packages/fastai/callback.py in on_batch_end(self, last_output, last_target, **kwargs)
291 if not is_listy(last_target): last_target=[last_target]
292 self.count += last_target[0].size(0)
–> 293 self.val += last_target[0].size(0) * self.func(last_output, *last_target).detach().cpu()
294
295 def on_epoch_end(self, **kwargs):

TypeError: object() takes no parameters

Any idea what I could have done wrong ? Thank you !