Why do I have negative loss value

I’m new to fast.ai (and AI in general) and I’m trying my hands on the home credit competition. Already, I hit two issues. The first is the data is unbalanced. For that, I reduced the size of the unbalanced part just to see what I can get when only looking at the main table for that competition (feature engineering will come later).

The second is that the loss value is negative…

When I do a lr_find(), it was returning e-5 errors, so I used

m.crit = lambda x,y : 1000.0 * F.nll_loss(x,y)

Then, instead of e-5 errors, I get


100% 3/3 [00:05<00:00, 1.68s/it]

epoch trn_loss val_loss
0 0.155606 -0.006989
1 0.140939 -0.006989
2 0.175914 -0.006989

I know I’m doing something wrong… can someone tell me why this is happening ?

Actually, I did find that changing the model to use regularization instead of classification

md = ColumnarModelData.from_data_frames(’’, trn_df = df, val_df = df_valid,
trn_y = y_train.astype(‘float’), val_y = y_valid.astype(‘float’),
cat_flds=cat_vars, bs=512, is_reg= True, is_multi=False)

(is_reg was False before)

gives me this output

epoch trn_loss val_loss
0 0.40384 0.399599
1 0.252705 0.217203
2 0.217781 0.237928

Since this is a classification problem, I’m still confused.

1 Like