diff --git a/README.md b/README.md index 66b9afc..64bc482 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,6 @@ Weights are available inside the [Releases tab](https://github.com/titu1994/kera -# Issue with clipping - -Currently dependent on Tensorflow backend for `tf.clip_by_value`. Will be backend independent after next release of Keras. - # Requirements - Keras 2.2.4+ & Tensorflow 1.12+ (Only supports TF backend for now). - Numpy diff --git a/adabound.py b/adabound.py index ae0cfc5..213e481 100644 --- a/adabound.py +++ b/adabound.py @@ -1,4 +1,3 @@ -import tensorflow as tf from keras import backend as K from keras.optimizers import Optimizer @@ -100,10 +99,8 @@ def get_updates(self, loss, params): # Compute the bounds step_size_p = step_size * K.ones_like(denom) step_size_p_bound = step_size_p / denom - # TODO: Replace with K.clip after releast of Keras > 2.2.4 - bounded_lr_t = m_t * tf.clip_by_value(step_size_p_bound, - lower_bound, - upper_bound) + bounded_lr_t = m_t * K.minimum(K.maximum(step_size_p_bound, + lower_bound), upper_bound) p_t = p - bounded_lr_t