Try updating your fastai library first. Since the current metrics.py module is

from .imports import *

from .torch_imports import *

def accuracy_np(preds, targs):

preds = np.argmax(preds, 1)

return (preds==targs).mean()

def accuracy(preds, targs):

preds = torch.max(preds, dim=1)[1]

return (preds==targs).float().mean()

def accuracy_thresh(thresh):

return lambda preds,targs: accuracy_multi(preds, targs, thresh)

def accuracy_multi(preds, targs, thresh):

return ((preds>thresh).float()==targs).float().mean()

Notice the different between your accuray() and the current up-to-date accuracy() function. Then, try using the current up-to-date notebook. For that part code it is now (using accuracy_np() )

log_preds,y = learn.TTA()

probs = np.mean(np.exp(log_preds),0)

accuracy_np(probs, y)

Further, check out the dimension of log_preds, and probs in your code. log_preds should be a 3D-array, then after average over the first dimension, probs should be a 2D-array. If probs is not a 2D-array, you get that error.