Keras 2 Released


(nima) #1

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.


AttributeError: 'DirectoryIterator' object has no attribute 'nb_class'
My experience keeping it on AWS free tier
(Jeremy Howard) #2

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…


(Rothrock) #3

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?


(adam menges) #4

thanks for being so responsive, excited for part 2


(Jeremy Howard) #5

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:


(Can Yi) #6

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


(Arno Khachatourian) #7

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


(Nolan Chan) #8

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


(Vishnu Subramanian) #9

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.


(Ville Laurikari) #10

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

fastai/courses/deeplearning1/nbs/utils.py 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 install-gpu.sh. Downgrading to Keras 1.x resolves the problem:

pip install 'keras<2'

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


(Chris Butler) #11

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…


(David Gutman) #12

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).


#13

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.


(Chris Butler) #14

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…


(David Gutman) #15

@chrizbo

Another thought - a lot of his documentation (maybe even source for Keras.io?) 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.


(Jeremy Tymes) #16

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


(Christopher) #17

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.


(libin_china) #18

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


(Jeremy Howard) #19

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


(libin_china) #20

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