Why fit is not showing metric?

I am trying to use fastai with a very basic vanilla pytorch model. But despite my definition of metrics, it is now showing the metrics while training and I don’t understand why.

Here is the code:

#fastai.__version__  1.0.25.dev0 
import torch
import fastai
from fastai import *
from fastai.vision import *
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.datasets import fetch_mldata
mnist = fetch_mldata('MNIST original')
X, y = mnist["data"], mnist["target"]
X_train, X_valid, y_train, y_valid = train_test_split(X, y, test_size=0.2, random_state=42)
# Normalization
mean = X_train.mean()
std = X_train.std()
X_train = (X_train-mean)/std
X_valid = (X_valid-mean)/std

# Numpy to Torch Tensor
X_train = torch.from_numpy(np.float32(X_train))
y_train = torch.from_numpy(y_train.astype(np.long))
X_valid = torch.from_numpy(np.float32(X_valid))
y_valid = torch.from_numpy(y_valid.astype(np.long))

train = torch.utils.data.TensorDataset(X_train, y_train)
valid = torch.utils.data.TensorDataset(X_valid, y_valid)

data = ImageDataBunch.create(train_ds = train, valid_ds=valid)
import torch.nn as nn

net = nn.Sequential(
    nn.Linear(28*28, 16),
    nn.Linear(16, 16),
    nn.Linear(16, 10),

opt=optim.SGD(net.parameters(), lr=1e-1)

fit(model=net, data=data, epochs=5, loss_func=loss_function, opt=opt, metrics=metrics)

Can anyone hint why?

1 Like

Maybe this is because my model and data are note fastai objects, but pytorch. even so, there should be a warning or something.
If I create a Learner from my data and model, metrics works ok.