Release Keras 2.3.0 · keras-team/keras (original) (raw)
Keras 2.3.0 is the first release of multi-backend Keras that supports TensorFlow 2.0. It maintains compatibility with TensorFlow 1.14, 1.13, as well as Theano and CNTK.
This release brings the API in sync with the tf.keras API as of TensorFlow 2.0. However note that it does not support most TensorFlow 2.0 features, in particular eager execution. If you need these features, use tf.keras.
This is also the last major release of multi-backend Keras. Going forward, we recommend that users consider switching their Keras code to tf.keras in TensorFlow 2.0. It implements the same Keras 2.3.0 API (so switching should be as easy as changing the Keras import statements), but it has many advantages for TensorFlow users, such as support for eager execution, distribution, TPU training, and generally far better integration between low-level TensorFlow and high-level concepts like Layer and Model. It is also better maintained.
Development will focus on tf.keras going forward. We will keep maintaining multi-backend Keras over the next 6 months, but we will only be merging bug fixes. API changes will not be ported.
API changes
- Add
size(x)to backend API. add_metricmethod added to Layer / Model (used in a similar way asadd_loss, but for metrics), as well as the metricsproperty.- Variables set as attributes of a Layer are now tracked in
layer.weights(includinglayer.trainable_weightsorlayer.non_trainable_weightsas appropriate). - Layers set as attributes of a Layer are now tracked (so the weights/metrics/losses/etc of a sublayer are tracked by parent layers). This behavior already existed for Model specifically and is now extended to all Layer subclasses.
- Introduce class-based losses (inheriting from
Lossbase class). This enables losses to be parameterized via constructor arguments. Loss classes added:MeanSquaredErrorMeanAbsoluteErrorMeanAbsolutePercentageErrorMeanSquaredLogarithmicErrorBinaryCrossentropyCategoricalCrossentropySparseCategoricalCrossentropyHingeSquaredHingeCategoricalHingePoissonLogCoshKLDivergenceHuber
- Introduce class-based metrics (inheriting from
Metricbase class). This enables metrics to be stateful (e.g. required for supported AUC) and to be parameterized via constructor arguments. Metric classes added:AccuracyMeanSquaredErrorHingeCategoricalHingeSquaredHingeFalsePositivesTruePositivesFalseNegativesTrueNegativesBinaryAccuracyCategoricalAccuracyTopKCategoricalAccuracyLogCoshErrorPoissonKLDivergenceCosineSimilarityMeanAbsoluteErrorMeanAbsolutePercentageErrorMeanSquaredErrorMeanSquaredLogarithmicErrorRootMeanSquaredErrorBinaryCrossentropyCategoricalCrossentropyPrecisionRecallAUCSparseCategoricalAccuracySparseTopKCategoricalAccuracySparseCategoricalCrossentropy
- Add
reset_metricsargument totrain_on_batchandtest_on_batch. Set this to True to maintain metric state across different batches when writing lower-level training/evaluation loops. If False, the metric value reported as output of the method call will be the value for the current batch only. - Add
model.reset_metrics()method to Model. Use this at the start of an epoch to clear metric state when writing lower-level training/evaluation loops. - Rename
lrtolearning_ratefor all optimizers. - Deprecate argument
decayfor all optimizers. For learning rate decay, use LearningRateSchedule objects in tf.keras.
Breaking changes
- TensorBoard callback:
batch_sizeargument is deprecated (ignored) when used with TF 2.0write_gradsis deprecated (ignored) when used with TF 2.0embeddings_freq,embeddings_layer_names,embeddings_metadata,embeddings_dataare deprecated (ignored) when used with TF 2.0
- Change loss aggregation mechanism to sum over batch size. This may change reported loss values if you were using sample weighting or class weighting. You can achieve the old behavior by making sure your sample weights sum to 1 for each batch.
- Metrics and losses are now reported under the exact name specified by the user (e.g. if you pass
metrics=['acc'], your metric will be reported under the string "acc", not "accuracy", and inverselymetrics=['accuracy']will be reported under the string "accuracy". - Change default recurrent activation to
sigmoid(fromhard_sigmoid) in all RNN layers.