Keras 3.0 backend set_value and get_value

I have recently upgraded to keras 3.0 and came to know the set_value method and get_value method are gone from the keras.backend module.
Are the functions moved to a different module? or is there a different way to access variables from keras like optimizer learnig rate steps?
I am currently using optimizer.variables way but If you know what happened to set_value and get_value please do answer.
Thank you

Hi @Sohail_Mohammad, Once you have import keras 3 set the keras back end to tensorflow and can use set_value and get_value methods. For example

import os

os.environ["KERAS_BACKEND"] = "tensorflow"

import keras
import tensorflow as tf

Keras: 3.0.4
Tensorflow: 2.15.0

K = tf.keras.backend 
v = K.variable(1.)

 # reassign
K.set_value(v, 2.)

 # increment
K.set_value(v, K.get_value(v) + 1)


Please refer to this gist. Thank You.

it is available from:

  • import tensorflow.python.keras.backend as K

and also from

  • import keras._tf_keras.keras.backend as K

but not from keras.api.backend