Hi,
Question
I’m new to TensorFlow and am trying to deploy the model trained by another lab. They used TensorFlow v.2.8 but, to have TensorFlow running on my MacBook (M1 chip), I installed v.2.16 in the virtual environment. This difference in TensorFlow version gave me an issue as they have a line: from tensorflow.keras.backend import function
that keeps giving me import error.
What I tried
 I tried to install v. 2.8 on Macbook but the kernel in Jupyter notebook keeps crashing and restarting.
 I tried to find the equivalent function in v.2.16 but cannot find it.
I wonder if there is a way for me to 1) either run v.2.8 on M1 Mac or 2) resolve the import issue when running from tensorflow.keras.backend import function
Thank you very much for helping
“Modified by moderator”
Hi @Katherine Welcome to the Tensorflow Forum ,
It seems like you’re encountering compatibility issues due to the difference in TensorFlow versions between your environment and the one used by the lab. Here are some potential solutions to consider:
Virtual Environment with TensorFlow 2.8
 If possible, try creating a virtual environment specifically for this project with TensorFlow 2.8 installed. This can help avoid conflicts with other versions of TensorFlow.
 Ensure that you’re using the correct pip command to install TensorFlow 2.8. You can specify the version using:
pip install tensorflow==2.8
Resolving Import Error
 The
tensorflow.keras.backend.function
function might have been deprecated or removed in TensorFlow 2.16. You can try using an alternative approach to achieve the same functionality. For example, you can use tf.function
decorator to create TensorFlow graphs from Python functions. Here’s an example:
import tensorflow as tf
@tf.function
def my_function(inputs):
# You can Write your code here
return outputs
# Call the function
result = my_function(input_data)

Model Complexity If the model is particularly complex, consider the computational resources available on your M1 Mac. Running large models with limited GPU or CPU power might require adjustments or training on a more powerful machine.

Community Resources Explore online resources, TensorFlow Documentation, and community forums for guidance on using TensorFlow with Apple Silicon.
Thank You !