Lesson 3 In-Class Discussion ✅

This is true but the difference is small; would not be enough to explain significant differences between validation and training losses, specially if you do several epochs.

Btw, on the camvid notebook, most of the time I get good results matching those from the class, but every now and then, I get into a weird accuracy zone that looks like this:

Simply rerunning the cells gets back into the proper 80-90% accuracy zone from the first pass, but occasionally will once again lead to these low accuracies…anyone have a similar experience, and if so, any explanation? Does the learning rate somehow nondeterministically enter a strange zone on the loss function map that it can’t get out of?

1 Like

Im facing the same issue but all the time. I couldn’t get good accuracies anytime at all!!


@apalepu23 which platform r u using to run?

ahh good to know I’m not alone! I’m using the standard fastai-suggested GCP setup. Hope that helps

Thanks, that fixed the same problem, on Gradient. Although now I have a new one!

TypeError: ufunc ‘add’ did not contain a loop with signature matching types dtype(’<U32’) dtype(’<U32’) dtype(’<U32’)

1 Like

https://forums.fast.ai/t/general-course-chat/24987/225?u=raghavab1992.
Let me know if reboot fixes the issue for u as well

Lauren - I was doing the sam e thing and hit the same roadblock! I solved it by changing the data object. try this

data = (ImageFileList.from_folder(path, extensions='.jpg')
        .random_split_by_pct() 
        .label_from_df(labels, label_cls=FloatList)
       )

I added in the label_cls=FloatList which tells fastai that it is a floats dataset and not a Classification one. Hope this helps!

2 Likes

Hello, I was running the NB for regression problem (head-pose) without any change made from my side and I got the following error when the data object is created:

data = (ImageItemList.from_folder(path)
    .split_by_valid_func(lambda o: o.parent.name=='13')
    .label_from_func(get_ctr, label_cls=PointsItemList)
    .transform(get_transforms(), tfm_y=True, size=(120,160))
    .databunch().normalize(imagenet_stats)
   )

ValueError: only one element tensors can be converted to Python scalars

Someone knows what should I update? btw my fastai version is ‘1.0.27’

1 Like

Facing the same issue
Can someone help out
It used to work fine until I pulled and conda installed the new updates (fastai version 1.0.27)
Working on Google Cloud if its any help

1 Like

when i call src.label_from_folder() it gives me an IndexError: index 0 is out of bounds for axis 0 with size 0.

hey, Sam, could you elaborate a bit more on how to solve this?

thank you!

hi Karan,

I hope your issue has been resolved. I have an issue above this issue you have in the data_lm part. :frowning: Could you share your nb how you get pass this? I think it has to do with my untar_url on IMDB. i have the following 3 files instead of what Jeremy has in his output. So i dont have a train or test folder for running “data_lm = (TextList.from_folder…”

Thank you so much!

[PosixPath(’/home/nbuser/courses/fast-ai/course-v3/nbs/data/imdb/classes.txt’),
PosixPath(’/home/nbuser/courses/fast-ai/course-v3/nbs/data/imdb/train.csv’),
PosixPath(’/home/nbuser/courses/fast-ai/course-v3/nbs/data/imdb/test.csv’)]

data_lm = (TextList.from_folder(path)
#Inputs: all the text files in path
.filter_by_folder(include=[‘train’, ‘test’])
#We may have other temp folders that contain text files so we only keep what’s in train and test
.random_split_by_pct(0.1)
#We randomly split and keep 10% (10,000 reviews) for validation
.label_for_lm()
#We want to do a language model so we label accordingly
.databunch(bs=bs))
data_lm.save(‘tmp_lm’)

@angelinayy, It was not for you and me to solve. The URL for IMDB used to point to a tgz file which contained only 3 txet files. The current URL (https://s3.amazonaws.com/fast-ai-nlp/imdb.tgz) has the right tgz file. If you click on the URL link and open the tgz file you will find that it contains directories like train, test etc.

So the issue is resolved now.

thanks!

nevermind. it seems to work now. thank you all the same!

While running this code chunk:

data = (src.transform(tfms, size=256)
        .databunch().normalize(imagenet_stats))

learn.data = data
data.train_ds[0][0].shape

learn.freeze()

learn.lr_find()
learn.recorder.plot()

This is where we resize the images to 256 to improve the f-score - but I’m running into CUDA Out of memory issues, despite restarting the kernel. I am also just loading the saved weights from the previous run, and thus not re-running any model. I’m using GCP Compute instance for training my models. Does anyone have a workaround for this?

1 Like

Try to reduce the batch size inside of the databunch method. That worked for me (e.g. bs=32)

I must be doing something wrong - even after decreasing the batch-size to 4, I’m still getting the out of memory error. There must be something that I’m missing.

Edit: My bad - I was adding that parameter to .transform() instead of .databunch(). It’s working now. Thanks, @jm0077

1 Like

Trying to conduct some experiments using unet from fastai library but couldnt get it work with some high resolution images…using batch size=1 as each image resolution is 8k*5k.
For some reason, batch size =1 isnt working for any dataset even for camvid.
Error when trying to access one batch of data


Error with lr_find

Error with fit_once_cycle

I am building language model for hindi but not able to load data . Every time kernel restarts. I have 32 gb ram and my data is of 10gb.
getting problem here:

data_lm = (TextFileList.from_folder(path)         
           #grab all the text files in path
           .label_const(0)           
           #label them all wiht 0s (the targets aren't positive vs negative review here)
           .split_by_folder(valid='test')         
           #split by folder between train and validation set
           .datasets() 
           #use `TextDataset`, the flag `is_fnames=True` indicates to read the content of the files passed
           .tokenize()
           #tokenize with defaults from fastai
           .numericalize()
           #numericalize with defaults from fastai
           .databunch(TextLMDataBunch))
           #use a TextLMDataBunch
---------------------------------------------------------------------------
MemoryError                               Traceback (most recent call last)
<ipython-input-6-be9b2c40e9af> in <module>
      3            .label_const(0)
      4            #label them all wiht 0s (the targets aren't positive vs negative review here)
----> 5            .split_by_folder(valid='test')
      6            #split by folder between train and validation set
      7            .datasets()

~/anaconda2/envs/hindinlu/lib/python3.6/site-packages/fastai/data_block.py in datasets(self, dataset_cls, **kwargs)
    232         "Create datasets from the underlying data using `dataset_cls` and passing along the `kwargs`."
    233         if dataset_cls is None: dataset_cls = self.dataset_cls()
--> 234         train = dataset_cls(*self.train.items.T, **kwargs)
    235         dss = [train]
    236         dss += [train.new(*o.items.T, **kwargs) for o in self.lists[1:]]

~/anaconda2/envs/hindinlu/lib/python3.6/site-packages/fastai/text/data.py in __init__(self, fns, labels, classes, mark_fields, encode_classes)
    199         for f in fns:
    200             with open(f,'r') as f: texts.append(''.join(f.readlines()))
--> 201         super().__init__(texts, labels, classes, mark_fields, encode_classes)
    202 
    203 class LanguageModelLoader():

~/anaconda2/envs/hindinlu/lib/python3.6/site-packages/fastai/text/data.py in __init__(self, texts, labels, classes, mark_fields, encode_classes)
    129     def __init__(self, texts:Collection[str], labels:Collection[Any]=None, classes:Collection[Any]=None,
    130                  mark_fields:bool=True, encode_classes:bool=True):
--> 131         texts = _join_texts(np.array(texts), mark_fields)
    132         super().__init__(texts, labels, classes, encode_classes)
    133 

MemoryError: 


I have divided my text file into small subsets but still same problem. I have monitored memory usage of my system also and its getting upto 95% then gets crash.
How you people load huge data?
@sgugger @radek