Chapter 6 - The first evaluation; Training the logistic regression model - Code doesn't work

I’m in Chapter 6 - The first evaluation.

  1. When I try to execute:

model.evaluate_generator(test_generator)

=> I get this error:

Then I rewrite this code like this:

model.evaluate_generator(test_generator, steps=15)

=> And it works:

image

  1. Similar problem is in “Training the logistic regression model”:

model.fit_generator(train_generator, validation_data=val_generator, epochs=5, workers=4)

I fixed this like this:

model.fit_generator(train_generator, steps_per_epoch=15, epochs=5, validation_data=val_generator, validation_steps=15, workers=4)

=> Why 15? I don’t know, I just put some number :relaxed:

Maybe it’s because I use this version:

image

But the way, I really like this book so far: now I know how to start up (this terminal thing, environment set put and launching Jupyter’s notebooks, which I’ve seen in advanced videos but didn’t know how they got this) AND Thank You for explaining math behind this stuff, those simple explanations was very helpful :blush:

That looks like you’re using a newer version of Keras. The code in the book only works with version 2.2.0.

Then I something missed out how to specify version of Keras when setting up Keras environment in challenge.

Ok, for the first time going through this book, I should better use your projects to get familiar with all this new stuff :wink:

Inside your active conda environment, type the following:

pip install -U keras==2.2.0

That should grab the right version of Keras for the book.

Thank You! It installed successfully, but I noticed some error messages about tensorflow versions. I guess I need to drop down to some earlier versions for tensorflow, too … or i can ignore those errors?

28

I think this is not a serious error, but just to be sure you could install an older version of TensorFlow. (Not sure which one, 1.10 perhaps.)

Had the same problem. Installing keras 2.2.0 and tensorflow 1.10 fixed it for me. Thanks!