Each epoch returns 0s for train_loss, valid_loss and error rate


I’m trying to run 10 epochs on the Food-101 dataset using ResNet50 and so far this is my output:

epoch train_loss valid_loss error_rate time
0 0.000000 0.000000 0.000000 21:05
1 0.000000 0.000000 0.000000 20:16
2 0.000000 0.000000 0.000000 20:17

Why could this be the case?

This is my code:

from fastai import *
from fastai.vision import *
from pathlib import Path
from numba import vectorize
from subprocess import call, run
import os, git, glob, shutil

train_image_path = Path('images/train/')
test_image_path = Path('images/test/')
path = Path('../Food-101')

food_names = get_image_files(train_image_path)
file_parse = r'/([^/]+)_\d+\.(png|jpg|jpeg)$'

data = ImageDataBunch.from_folder(train_image_path, test_image_path, valid_pct=0.2, ds_tfms=get_transforms(), size=224)

learn = cnn_learner(data, models.resnet50, metrics=error_rate)

Ran into this issue today, so I’ll just post what the problem was for me in case somebody else encounters it (it also happens in fastai v2).

The 0 loss and error rate occurred because the labels were wrong. Check the vocab of your dataloader.