April 2017
Intermediate to advanced
318 pages
7h 40m
English
The Keras 2.0 changes implied the need to rethink some APIs. For full details, please refer to the release notes (https://github.com/fchollet/keras/wiki/Keras-2.0-release-notes). This module legacy.py summarizes the most impactful changes and prevents warnings when using Keras 1.x calls:
""Utility functions to avoid warnings while testing both Keras 1 and 2."""import keraskeras_2 = int(keras.__version__.split(".")[0]) > 1 # Keras > 1def fit_generator(model, generator, epochs, steps_per_epoch): if keras_2: model.fit_generator(generator, epochs=epochs, steps_per_epoch=steps_per_epoch) else: model.fit_generator(generator, nb_epoch=epochs, samples_per_epoch=steps_per_epoch)def fit(model, x, y, nb_epoch=10, *args, **kwargs): if keras_2: ...