CyberZHG/keras-radam

ValueError: ('Could not interpret optimizer identifier:', <keras_radam.optimizers.RAdam object at 0x7fd0dab35358>)

zirlman opened this issue · 4 comments

Does this implementation work with TF 2.0?
I've tried the optimizer with this notebook
But after running the notebook the following Error occurs:
ValueError: ('Could not interpret optimizer identifier:', <keras_radam.optimizers.RAdam object at 0x7fd0dab35358>)

The modification is shown bellow

`tf.keras.backend.clear_session()
tf.random.set_seed(51)
np.random.seed(51)
train_set = windowed_dataset(x_train, window_size=60, batch_size=100, shuffle_buffer=shuffle_buffer_size)
model = tf.keras.models.Sequential([
tf.keras.layers.Conv1D(filters=60, kernel_size=5,
strides=1, padding="causal",
activation="relu",
input_shape=[None, 1]),
tf.keras.layers.LSTM(60, return_sequences=True),
tf.keras.layers.LSTM(60, return_sequences=True),
tf.keras.layers.Dense(30, activation="relu"),
tf.keras.layers.Dense(10, activation="relu"),
tf.keras.layers.Dense(1),
tf.keras.layers.Lambda(lambda x: x * 400)
]

model.compile(loss=tf.keras.losses.Huber(),
optimizer=RAdam(),
metrics=["mae"])
history = model.fit(train_set,epochs=250)`

EDIT:
I've set the environment variable TF_KERAS to 1
import os os.environ['TF_KERAS'] = '1'

I'm getting the same error, even with: import os os.environ['TF_KERAS'] = '1'

I'm running tf.keras with Tensorflow 2.0 beta

Anything else I might try?

Add it to environment variables before import this library.

or you can:

TF_KERAS=1 python xxx.py

@CyberZHG Thank you. If anyone else encounters the same problem you need to set the environment variable before you import this library.
You can do it like this:
import os os.environ['TF_KERAS'] = '1'

or %env TF_KERAS = 1 in your notebook