Just as a note, here are the changes I had to do on utils.py to get the lesson 1 working Keras 2 on Windows (likely same changes required on Linux):
utils.py
#import cPickle as pickle
import six.moves.cPickle as pickle
#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
Additionally I had to change set the image dim ordering via code, changing image_dim_ordering in keras.json didn’t seem to work (changing backend worked though). Make sure to do it as early as possible, personally I’m doing right after the %matplotlib
line
from keras import backend backend.set_image_dim_ordering('th')
Also, nb_class
seems to have been renamed to num_class
and nb_sample
to samples
, so when running Vgg16.fit
, they need to aliased (or probably better to just modify vg16.py directly):
batches = vgg.get_batches(path+'train', batch_size=batch_size) val_batches = vgg.get_batches(path+'valid', batch_size=batch_size*2) batches.nb_class = batches.num_class batches.nb_sample = batches.samples val_batches.nb_class = batches.num_class val_batches.nb_sample = val_batches.samples vgg.finetune(batches) vgg.fit(batches, val_batches, nb_epoch=1)