Kaggle's Whale Competition

Same issue with latest fastai.

Its the labels there’s an issue with the label matching data if am not mistaken. I have had to put a hold on my AI learning for now. So switched off and moved away from this.

Checkout the Kaggle page notebooks and see how they break the data down. That helped me a lot before I stopped this.

I have the same problem with the Whale competition when trying to call .fit() on the learner. Apparently there is no solution on these forums yet.

I think we can figure this out :slight_smile:

Can someone please share the first 2 - 3 rows from the input csv file? You can do head -n 3 file_name.csv in terminal to get this.

Also, could someone please read this into a dataframe and check the type of the label column? You can get this by doing type(df.loc[0, 'label_column_name'])

I did a little bit of investigating and I believe that the problem occurs when the number of classes in the validation set is greater than the number of classes in the training set.

3 Likes

Probably because of validation set not representing the whole class set. Moreover, since many of the classes have only a single sample in the dataset, when random validation split is done, few such samples go to validation set. Thereby, the training set also does not represent the corresponding classes. So, many of the classes stay only in validation set or training set.

1 Like

I think @Subhanandh and @francis are onto something. When I set val_idxs = 0, I am able to call learn.fit() with no error now.

1 Like

So does that mean in this case you’re training without a validation set?

If the problem is that there are too many classes with just one image (so training and validation sets contain different classes), couldn’t we do data augmentation, then use augmented data to create a validation set? Trying to figure it out now, but I’m still a pretty slow coder :slight_smile:

Does anyone have a update to this? I think it’s surprising that everyone on the fast.ai side of things is having issues; however nothing seems to be mentioned on the Kaggle forums.

You can see this topic

I spotted this thread linked over from the Kaggle competition and as a big fan of FastAI (recently spent many nights working through Part 2!) I thought I’d share my notebook which I got working. I didn’t actually hit the problems mentioned above, but hopefully someone will be able to see what I’ve done differently: https://github.com/jamesr2323/deep_learning/blob/master/experiments/whales_baseline.ipynb

Also before posting the notebook I updated FastAI to the latest commit on Github and hit an issue initialising the test set, which I’ve submitted a PR for https://github.com/fastai/fastai/pull/515 .If you have the same issue you can use that change as a temporary work-around.

4 Likes

Thanks @jamesrees for sharing your notebook, your data import worked for me and helped me avoid the below error when I tried lean.fit

RuntimeError: cuda runtime error (59) : device-side assert triggered

By creating a reference dictionary and replacing the given whale ids with integers I no longer encountered the assert error. So I guess as mentioned above there is an issue with dealing with the original labels given.

If I load the original label file [train.csv] straight into a pandas dataframe I get the below column types:

Image:    object
Id:       oject

Creating a reference dictionary and replacing the original whale Ids with integer labels allows my learn.fit to run without errors

Image:    object
Id:       int64

If anyone is getting the above error, try replacing the whale Id labels with Integer lables as per @jamesrees notebook here:

https://github.com/jamesr2323/deep_learning/blob/master/experiments/whales_baseline.ipynb

1 Like

I’ve just started working on the whale competition. I’m pretty new to this, but it looks like the grayscale images in the dataset are 3 channel images where R==G==B. I think this is why @jamesrees notebook works with resnet34 without needing to convert image channels.

Following some of the ideas in a Kaggle kernel on data processing for this competition (https://www.kaggle.com/lextoumbourou/humpback-whale-id-data-and-aug-exploration), I like the idea of creating 3 channel grayscale versions of all the color images as part of data augmentation.

It looks like torchvision has a function to do exactly this - see Grayscale and to_grayscale in https://pytorch.org/docs/master/torchvision/transforms.html

Is there a way to incorporate this in aug_tfms on tfms_from_model? Or would some other pipeline need to be developed?