I am getting the following error when I try to run the finetune method as shown in the Lesson 1 notebook.
‘DirectoryIterator’ object has no attribute ‘nb_class’
Tab completion on batches shows num_classes and not nb_classes.
Anyone face similar issue ?
rteja1113
(Ravi Teja Gutta)
June 5, 2017, 6:08am
#2
Hi @deepdreams , what keras version are you using ? some of the methods/properties were deprecated for keras2.Part1 was taught in 1.2
Thanks. Yeah, i had to modify the code a little bit to make it work. I am on Keras version 2.x. On a different note, are you running in the cloud or have set up everything locally.
Hey @deepdreams , would you mind sharing the code tweak you made to allow Keras v2 to work? I think it might help me. Thanks.
deepdreams
(Deep Learner)
June 29, 2017, 6:16am
#5
Most of the changes need to be done in vgg16.py file. batches/val_batches/test_batches objects no longer have nb_class
and nb_samples
. These have been replaced with num_class
and samples
If you don’t want to change vgg16.py, you can add something similar to the following in your main notebook.
1 Like
deepdreams
(Deep Learner)
June 29, 2017, 6:44am
#6
If you want to modify vgg16.py, her are some examples where code would have to change
Updated self.ft(batches.nb_class)
to self.ft(batches.num_class)
Updated batches.nb_sample
to batches.samples
and val_batches.nb_sample
to val_batches.samples
pradeep718
(Sathya Pradeep)
September 24, 2017, 12:55pm
#7
Hi
I am getting following when i execute
the following
vgg.finetune(batches)
AttributeErrorTraceback (most recent call last)
in ()
4 #val_batches .nb_class = val_batches.num_class
5 #val_batches .nb_sample = val_batches.sample
----> 6 vgg.finetune(batches)
/home/nbuser/courses/fastai/deeplearning1/nbs/vgg16.pyc in finetune(self, batches)
180 “”"
181 #self .ft(batches.nb_class) # commented this line due to error
–> 182 self.ft(batches.num_class)
183 classes = list(iter(batches.class_indices)) # get a list of all the class labels
184
AttributeError: ‘DirectoryIterator’ object has no attribute ‘num_class’
can someone help ?
saagr
November 15, 2017, 10:16am
#8
Hi Pradeep,
Were you able to find a solution to this issue? I am facing the exact same issue. FYI, I am running to code on a local machine.
SOLVED: My bad. The path I had given was not correct.
Edit: I still have the same issue.
gnavink
(Navin Kumar)
November 15, 2017, 10:27am
#9
@saagr , which version of keras are running, part 1 of the course uses keras 1.1.0.
If you are using AWS setup as mentioned by jeremy the code should run without any modifications
saagr
November 15, 2017, 10:34am
#10
@gnavink : I am using the latest keras version - 2.1.1. I have made changes to the utils and vgg16 files as recommended here and this thread.
I am not running it on AWS. I wanted to run it on my local machine.
jun
(j.w)
November 17, 2017, 12:34am
#12
same problem after modification.still can’t figure it out
jun
(j.w)
November 17, 2017, 12:35am
#13
I too am running it on my local PC and can not get rid of the effor of “AttributeError: ‘DirectoryIterator’ object has no attribute ‘num_class’”
jun
(j.w)
November 17, 2017, 7:06am
#14
figured it out that in Keras 2.1 we should use 'num_classes
’ instead of ‘num_class
’. Hope this will help for you.
3 Likes
saagr
November 17, 2017, 12:22pm
#15
Yes. This helped! Thanks.