Keras 2 Released

Looks like Keras 2 was just released.

Some major changes are in there, but it’s all backwards compatible (for the most part).

Part 1 of the class’s TimeDistributedDense layer was removed, which probably should be discussed.


I believe we always used TimeDistributed(Dense(…)), which was not removed. Let me know if you spot anywhere we used the removed version.

In general, please folks let me know any time you find any incompatibilities with the provided code, or think that there are better ways to express it in the new API. I’ve been thinking recently about the best ways to keep the content up to date, so this will be a good test…


I’m still very new to python and anaconda. So far I’ve set up with python 3, keras, and theano. Can anybody share advice on how to upgrade?

Do I create a new environment? Or just replace what I’ve got.

Should I select the integrated tensor flow version or the multi-backend one?

thanks for being so responsive, excited for part 2

I’d very strongly suggest using python 2.7 and keras 1 and theano if you’re new to python. Otherwise you’ll need to port the code as you go, which will be a distraction from learning deep learning.

You’ll be learning py3 and tensorflow in part 2 of the course - so you won’t miss out! :slight_smile:


I can’t wait to see the exciting courses in part-2, hope these amazing courses will be released soon~

1 Like

activity_l1 and activity_l2 have been removed from keras.regularizers in version 2.
This causes an error when trying to import the module. It doesn’t seem that actually makes use of these imports, though.


I also encountered more than a few errors using Keras 2 on Lesson 1 (Dogs vs. Cats). I wasn’t able to resolve them, but rolling back to Keras 1.1.1 (uninstall Keras 2 and manually install Keras 1.1.1) allowed me to continue on Lesson 1

Keras 2 ImageGenerator method flow is not working for loading precomputed convolution features . They have included a check which verifies the number of channels. Any ideas for a work around.

I can confirm that Keras 2 doesn’t work on Lesson 1. I am getting this import error:

fastai/courses/deeplearning1/nbs/ in <module>()
     40 from keras.layers import TimeDistributed, Activation, SimpleRNN, GRU
     41 from keras.layers.core import Flatten, Dense, Dropout, Lambda
---> 42 from keras.regularizers import l2, activity_l2, l1, activity_l1
     43 from keras.layers.normalization import BatchNormalization
     44 from keras.optimizers import SGD, RMSprop, Adam

ImportError: cannot import name activity_l2

I am using an Ubuntu box (not on AWS), set up with Downgrading to Keras 1.x resolves the problem:

pip install 'keras<2'

I suggest that is changed to use Keras 1.x, like above, until all materials have been updated to Keras 2.

1 Like

Is there a place we can view the Keras 1.1 (or 1.x) documentation?

I can go back in github to the 1.x version via a branch, but most of the docs are auto-generated it seems…

The code is very well documented, so if you are using version 1 probably best to look directly at the source. (There may be an old version of the documentation somewhere, but hey have updated the main website to reflect 2.0).

Using pyenv to separate my Python versions and all the related virtualenvs helped me a lot. pyenv is very handy and easy to use if you need to create virtualenvs in different versions of Python.

Ok, I’ll check that out.

I was also hoping to use the docs for listings of methods, etc. I was trying to run this Keras tutorial of cats and dogs, but it is based on Keras 2.x:

The part that was tripping me up is that Conv2D had a different init method and the backend object had different methods…


Another thought - a lot of his documentation (maybe even source for comes from his github, which should have previous versions saved.

You could find examples for older versions of Keras in the previous commits of his other repos.

I generated and pushed the docs for 1.1.1 and 1.2.2: Keras Docs


This is awesome, we put in a request to François to keep up the old docs somewhere as they get swapped out immediately. Hopefully, he does that as there are a lot of small changes that are breaking things.

keras needs tensorflow, while tensorflow only support py3, it seems doesn’t work

No it doesn’t need tensorflow. In this part of the course we use it with theano.

But what this message meaning? “Using Tensorflow backend”, and when I run utils, always return “no module name Tensorflow”.