Code Monkey home page Code Monkey logo

Comments (5)

Jayoprell avatar Jayoprell commented on May 23, 2024 23

I' ve see this problem in the course forums and it has been solved now. The version of keras are caused the problem. So all you need to do is as follows:
Make some changes to utils.py if you are using keras 2.0+:
from keras.regularizers import l2, activity_l2, l1, activity_l1 ----> from keras.regularizers import l2, l1
from keras.utils.layer_utils import layer_from_config -----> from keras.layers import deserialize as layer_from_config

from courses.

royshouvik avatar royshouvik commented on May 23, 2024 1

I faced the same issue on trying to run the lesson 1 notebook on Crestle. Here's what I did

  1. On a terminal
    pip install keras==1.2.2

  2. Restart Jupyter notebook.

  3. Verify Keras version using python -c 'import keras; print(keras.__version__)'

Hope it helps.

from courses.

almandsky avatar almandsky commented on May 23, 2024

I think you are using keras 2.0+. You can try install the keras 1.2.2

pip install keras=1.2.2

otherwise you may need to make some changes to the utils.py as @Jayoprell mentioned above. I also need to modify the vgg16.py to make it work in my laptop.

--- a/deeplearning1/nbs/vgg16.py
+++ b/deeplearning1/nbs/vgg16.py
@@ -174,7 +174,7 @@ class Vgg16():
                 batches : A keras.preprocessing.image.ImageDataGenerator object.
                           See definition for get_batches().
         """
-        self.ft(batches.nb_class)
+        self.ft(batches.num_class)
         classes = list(iter(batches.class_indices)) # get a list of all the class labels
         
         # batches.class_indices is a dict with the class name as key and an index as value
@@ -209,8 +209,8 @@ class Vgg16():
             Fits the model on data yielded batch-by-batch by a Python generator.
             See Keras documentation: https://keras.io/models/model/
         """
-        self.model.fit_generator(batches, samples_per_epoch=batches.nb_sample, nb_epoch=nb_epoch,
-                validation_data=val_batches, nb_val_samples=val_batches.nb_sample)
+        self.model.fit_generator(batches, samples_per_epoch=batches.samples, nb_epoch=nb_epoch,
+                validation_data=val_batches, nb_val_samples=val_batches.samples)
 
 
     def test(self, path, batch_size=8):
@@ -227,5 +227,5 @@ class Vgg16():
     
         """
         test_batches = self.get_batches(path, shuffle=False, batch_size=batch_size, class_mode=None)
-        return test_batches, self.model.predict_generator(test_batches, test_batches.nb_sample)
+        return test_batches, self.model.predict_generator(test_batches, test_batches.samples)

from courses.

ethirajsrinivasan avatar ethirajsrinivasan commented on May 23, 2024

image

In keras 2 even after changing nb_class to num_class i am getting the error as above

from courses.

ak9250 avatar ak9250 commented on May 23, 2024

@royshouvik after doing pip install I am getting AttributeError: 'module' object has no attribute 'HiddenLayer'

from courses.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.