-
Notifications
You must be signed in to change notification settings - Fork 651
Info for Google Colab users about TensorFlow Quantum 0.7.5 #959
Copy link
Copy link
Closed
Labels
area/dependenciesInvolves libraries or other software that TFQ depends onInvolves libraries or other software that TFQ depends onarea/docsInvolves documentation – problems, ideas, requestsInvolves documentation – problems, ideas, requestsarea/kerasInvolves Keras, Keras-TFQ interfaces, or related topicsInvolves Keras, Keras-TFQ interfaces, or related topicsarea/tensorflowInvolves TensorFlowInvolves TensorFlowplatform/colabGoogle Colab issues and PRsGoogle Colab issues and PRsplatform/linuxLinux issues and PRs.Linux issues and PRs.
Metadata
Metadata
Assignees
Labels
area/dependenciesInvolves libraries or other software that TFQ depends onInvolves libraries or other software that TFQ depends onarea/docsInvolves documentation – problems, ideas, requestsInvolves documentation – problems, ideas, requestsarea/kerasInvolves Keras, Keras-TFQ interfaces, or related topicsInvolves Keras, Keras-TFQ interfaces, or related topicsarea/tensorflowInvolves TensorFlowInvolves TensorFlowplatform/colabGoogle Colab issues and PRsGoogle Colab issues and PRsplatform/linuxLinux issues and PRs.Linux issues and PRs.
As noted in the release notes for TensorFlow Quantum (TFQ) 0.7.5, this version is compatible with TensorFlow 2.16 and Keras 2; however, Colab has version 2.19 preinstalled, and downgrading TensorFlow (TF) in Colab leads to some behaviors that may be confusing. This note is an attempt to provide some clarifications and guidance.
First, please make sure to install TF 2.16.2 and TFQ 0.7.5 with a shell command in a notebook cell early in your Colab notebook:
!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5After that, and before you import TensorFlow or TensorFlow Quantum in your Python program, you need to set the environment variable
TF_USE_LEGACY_KERAS=1. Here is a code snippet you can place before the first import oftensorflowortensorflow_quantum:If your code imports Keras directly, also alias
kerastotf_keras:When you run your notebook, immediately after Colab finishes the
!pip install …command, two things will happen:After that, things should work normally. You can find examples of using the commands above in the tutorial notebooks provided with TensorFlow Quantum.