diff --git a/docs/install.md b/docs/install.md index 61338735c..fba8cf72d 100644 --- a/docs/install.md +++ b/docs/install.md @@ -10,24 +10,23 @@ There are a few ways to set up your environment to use TensorFlow Quantum (TFQ): Python's pip package manager. * Or build TensorFlow Quantum from source. -TensorFlow Quantum is supported on Python 3.9, 3.10, and 3.11 and depends directly on [Cirq](https://github.com/quantumlib/Cirq). +TensorFlow Quantum is supported on Python 3.10, 3.11, and 3.12 and depends directly on [Cirq](https://github.com/quantumlib/Cirq). ## Pip package ### Requirements * pip 19.0 or later (requires `manylinux2014` support) -* [TensorFlow == 2.15.0](https://www.tensorflow.org/install/pip) +* [TensorFlow == 2.16.2](https://www.tensorflow.org/install/pip) See the [TensorFlow install guide](https://www.tensorflow.org/install/pip) to set up your Python development environment and an (optional) virtual environment. Upgrade `pip` and install TensorFlow -
@@ -43,13 +42,13 @@ Install the latest stable release of TensorFlow Quantum: Success: TensorFlow Quantum is now installed. -Nightly builds which might depend on newer version of TensorFlow can be installed with: + - -pip3 install --upgrade pip-pip3 install tensorflow==2.15.0+pip3 install tensorflow==2.16.2
- pip3 install -U tfq-nightly
-
-
+
+
+
+
+
## Build from source
@@ -77,6 +76,9 @@ Go to your workspace directory and make a virtual environment for TFQ developmen
+Make sure that the virtual environment is activated for the rest of the steps
+below, and every time you want to use TFQ in the future.
+
### 3. Install Bazel
As noted in the TensorFlow
@@ -84,7 +86,8 @@ As noted in the TensorFlow
guide, the Bazel
build system will be required.
-Our latest source builds use TensorFlow 2.15.0. To ensure compatibility we use `bazel` version 6.5.0. To remove any existing version of Bazel:
+Our latest source builds use TensorFlow 2.16.2. To ensure compatibility we use
+`bazel` version 6.5.0. To remove any existing version of Bazel:
sudo apt-get remove bazel@@ -120,82 +123,83 @@ Finally, confirm installation of the correct `bazel` version: ### 4. Build TensorFlow from source -Here we adapt instructions from the TensorFlow [build from source](https://www.tensorflow.org/install/source) -guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version 2.15.0. - -Download the -TensorFlow source code: +TensorFlow Quantum is compatible with TensorFlow version 2.16.2. To build +TensorFlow from sources, download the TensorFlow +source code by cloning the git repository, then switch to the `r2.16` +branch:-Be sure the virtual environment you created in step 2 is activated. Then, install the TensorFlow dependencies: +Be sure the virtual environment you created in step 2 is activated, then follow +the TensorFlow instructions for how to [build and install the pip +package](https://www.tensorflow.org/install/source#build_and_install_the_pip_package) +on your system. + +Note: it may take over an hour to build TensorFlow. + +After the build is complete, and you have installed the pip package, leave the +TensorFlow directory before moving on to step 5:git clone https://github.com/tensorflow/tensorflow.gitcd tensorflow-git checkout v2.15.0+git checkout r2.16--Configure the TensorFlow build. When asked for the Python interpreter and library locations, be sure to specify locations inside your virtual environment folder. The remaining options can be left at default values. +### 5. Download TensorFlow Quantum + +We use the standard [fork and pull request workflow](https://guides.github.com/activities/forking/) for contributions. After forking from the [TensorFlow Quantum](https://github.com/tensorflow/quantum) GitHub page, download the source of your fork and install the requirements:pip install -U pip six numpy wheel setuptools mock 'future>=0.17.1'-pip install -U keras_applications --no-deps-pip install -U keras_preprocessing --no-deps-pip install numpy==1.23.5-pip install packaging requests+cd ..--Build the TensorFlow package (Since TF v2.8, `_GLIBCXX_USE_CXX11_ABI` is set to 1, and the c++ codes are all compiled with `-std=c++17`): +### 6. Build and install TensorFlow Quantum + +Be sure the virtual environment you created in step 2 is activated. Then, run +the command below to install the TensorFlow Quantum dependencies:./configure+git clone https://github.com/username/quantum.git+cd quantum+pip install -r requirements.txt--Note: It may take over an hour to build the package. - -After the build is complete, install the package and leave the TensorFlow directory: +Next, use TensorFlow Quantum's `configure.sh` script to configure the TFQ +build:bazel build -c opt --cxxopt="-O3" --cxxopt="-march=native" --cxxopt="-std=c++17" --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" //tensorflow/tools/pip_package:build_pip_package+pip install -r requirements.txt--### 5. Download TensorFlow Quantum - -We use the standard [fork and pull request workflow](https://guides.github.com/activities/forking/) for contributions. After forking from the [TensorFlow Quantum](https://github.com/tensorflow/quantum) GitHub page, download the source of your fork and install the requirements: +Now build TensorFlow Quantum:./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg-pip install /tmp/tensorflow_pkg/name_of_generated_wheel.whl-cd ..+./configure.sh-- -### 6. Build the TensorFlow Quantum pip package - -Build the TensorFlow Quantum pip package and install: +After the build is complete, run the next two commands to create a Python +package for TensorFlow Quantum and write it to a temporary directory (we use +`/tmp/tfquantum/` in this example), then install it using pip:git clone https://github.com/username/quantum.git-cd quantum-pip install -r requirements.txt+bazel build -c opt --cxxopt="-O3" --cxxopt="-march=native" release:build_pip_package-diff --git a/docs/tutorials/barren_plateaus.ipynb b/docs/tutorials/barren_plateaus.ipynb index 345e910ec..99fe12733 100644 --- a/docs/tutorials/barren_plateaus.ipynb +++ b/docs/tutorials/barren_plateaus.ipynb @@ -88,65 +88,68 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "TorxE5tnkvb2" - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "!pip install tensorflow==2.15.0" + "Install TensorFlow and TensorFlow Quantum:" ] }, { - "cell_type": "markdown", - "metadata": { - "colab_type": "text", - "id": "FxkQA6oblNqI" - }, + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ - "Install TensorFlow Quantum:" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "saFHsRDpkvkH" - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow-quantum==0.7.3" + "!pip install tensorflow-quantum==0.7.4" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J" - }, + "metadata": {}, "outputs": [], "source": [ "# Update package resources to account for version changes.\n", "import importlib, pkg_resources\n", - "\n", "importlib.reload(pkg_resources)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configure the use of Keras 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" + ] + }, { "cell_type": "markdown", "metadata": { "colab_type": "text", - "id": "1PaclXeSrrMW" + "id": "F1L8h1YKUvIO" }, "source": [ - "Now import TensorFlow and the module dependencies:" + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" ] }, { @@ -509,13 +512,21 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", "name": "python", - "version": "3.10.9 (main, Dec 7 2022, 13:47:07) [GCC 12.2.0]" + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" }, "vscode": { "interpreter": { @@ -524,5 +535,5 @@ } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 4 } diff --git a/docs/tutorials/gradients.ipynb b/docs/tutorials/gradients.ipynb index 166daf4cb..1aa45fb74 100644 --- a/docs/tutorials/gradients.ipynb +++ b/docs/tutorials/gradients.ipynb @@ -90,65 +90,68 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "TorxE5tnkvb2" - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "!pip install tensorflow==2.15.0" + "Install TensorFlow and TensorFlow Quantum:" ] }, { - "cell_type": "markdown", - "metadata": { - "colab_type": "text", - "id": "OIbP5hklC338" - }, + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ - "Install TensorFlow Quantum:" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "saFHsRDpkvkH" - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow-quantum==0.7.3" + "!pip install tensorflow-quantum==0.7.4" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J" - }, + "metadata": {}, "outputs": [], "source": [ "# Update package resources to account for version changes.\n", "import importlib, pkg_resources\n", - "\n", "importlib.reload(pkg_resources)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configure the use of Keras 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" + ] + }, { "cell_type": "markdown", "metadata": { "colab_type": "text", - "id": "MkTqyoSxGUfB" + "id": "F1L8h1YKUvIO" }, "source": [ - "Now import TensorFlow and the module dependencies:" + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" ] }, { @@ -810,13 +813,21 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", "name": "python", - "version": "3.10.9 (main, Dec 7 2022, 13:47:07) [GCC 12.2.0]" + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" }, "vscode": { "interpreter": { @@ -825,5 +836,5 @@ } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 4 } diff --git a/docs/tutorials/hello_many_worlds.ipynb b/docs/tutorials/hello_many_worlds.ipynb index 759c8afaf..b8d798736 100644 --- a/docs/tutorials/hello_many_worlds.ipynb +++ b/docs/tutorials/hello_many_worlds.ipynb @@ -91,66 +91,60 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "TorxE5tnkvb2", - "vscode": { - "languageId": "python" - } - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "!pip install tensorflow==2.15.0" + "Install TensorFlow and TensorFlow Quantum:" ] }, { - "cell_type": "markdown", - "metadata": { - "colab_type": "text", - "id": "FxkQA6oblNqI" - }, + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ - "Install TensorFlow Quantum:" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "saFHsRDpkvkH", - "vscode": { - "languageId": "python" - } - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow-quantum==0.7.3" + "!pip install tensorflow-quantum==0.7.4" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J", - "vscode": { - "languageId": "python" - } - }, + "metadata": {}, "outputs": [], "source": [ "# Update package resources to account for version changes.\n", "import importlib, pkg_resources\n", - "\n", "importlib.reload(pkg_resources)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configure the use of Keras 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" + ] + }, { "cell_type": "markdown", "metadata": { @@ -158,7 +152,7 @@ "id": "F1L8h1YKUvIO" }, "source": [ - "Now import TensorFlow and the module dependencies:" + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" ] }, { @@ -794,7 +788,7 @@ "id": "yJSC9qH76pJA" }, "source": [ - "The model attempts to output the correct correct measurement value of $\\hat{Z}$ for each command. The commands and correct values are defined below." + "The model attempts to output the correct measurement value of $\\hat{Z}$ for each command. The commands and correct values are defined below." ] }, { @@ -1333,11 +1327,23 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 4 } diff --git a/docs/tutorials/mnist.ipynb b/docs/tutorials/mnist.ipynb index e3fc0f8aa..65a9a55d9 100644 --- a/docs/tutorials/mnist.ipynb +++ b/docs/tutorials/mnist.ipynb @@ -88,65 +88,68 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "TorxE5tnkvb2" - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "!pip install tensorflow==2.15.0" + "Install TensorFlow and TensorFlow Quantum:" ] }, { - "cell_type": "markdown", - "metadata": { - "colab_type": "text", - "id": "FxkQA6oblNqI" - }, + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ - "Install TensorFlow Quantum:" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "saFHsRDpkvkH" - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow-quantum==0.7.3" + "!pip install tensorflow-quantum==0.7.4" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J" - }, + "metadata": {}, "outputs": [], "source": [ "# Update package resources to account for version changes.\n", "import importlib, pkg_resources\n", - "\n", "importlib.reload(pkg_resources)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configure the use of Keras 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" + ] + }, { "cell_type": "markdown", "metadata": { "colab_type": "text", - "id": "hdgMMZEBGqyl" + "id": "F1L8h1YKUvIO" }, "source": [ - "Now import TensorFlow and the module dependencies:" + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" ] }, { @@ -329,8 +332,7 @@ "metadata": { "colab": {}, "colab_type": "code", - "id": "lbhUdBFWojhE", - "scrolled": false + "id": "lbhUdBFWojhE" }, "outputs": [], "source": [ @@ -563,8 +565,7 @@ "metadata": { "colab": {}, "colab_type": "code", - "id": "w3POmUEUojhe", - "scrolled": false + "id": "w3POmUEUojhe" }, "outputs": [], "source": [ @@ -1038,8 +1039,7 @@ "metadata": { "colab": {}, "colab_type": "code", - "id": "70TOM6r-ojiZ", - "scrolled": false + "id": "70TOM6r-ojiZ" }, "outputs": [], "source": [ @@ -1120,13 +1120,21 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", "name": "python", - "version": "3.10.9 (main, Dec 7 2022, 13:47:07) [GCC 12.2.0]" + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" }, "vscode": { "interpreter": { @@ -1135,5 +1143,5 @@ } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 4 } diff --git a/docs/tutorials/noise.ipynb b/docs/tutorials/noise.ipynb index 997b2a0ee..fc8141df1 100644 --- a/docs/tutorials/noise.ipynb +++ b/docs/tutorials/noise.ipynb @@ -75,44 +75,89 @@ "## Setup" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Install TensorFlow and TensorFlow Quantum:" + ] + }, { "cell_type": "code", "execution_count": null, - "metadata": { - "id": "J2CRbYRqrLdt" - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow==2.15.0 tensorflow-quantum==0.7.3" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "id": "QStNslxBwgte" - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install -q git+https://github.com/tensorflow/docs" + "!pip install tensorflow-quantum==0.7.4" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J" - }, + "metadata": {}, "outputs": [], "source": [ "# Update package resources to account for version changes.\n", "import importlib, pkg_resources\n", - "\n", "importlib.reload(pkg_resources)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configure the use of Keras 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Install TensorFlow Docs so that we can use the plotting functions:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "QStNslxBwgte" + }, + "outputs": [], + "source": [ + "!pip install -q git+https://github.com/tensorflow/docs" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "F1L8h1YKUvIO" + }, + "source": [ + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" + ] + }, { "cell_type": "code", "execution_count": null, @@ -814,7 +859,7 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -828,9 +873,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.8" + "version": "3.11.9" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 4 } diff --git a/docs/tutorials/qcnn.ipynb b/docs/tutorials/qcnn.ipynb index f30bacce7..4417218e9 100644 --- a/docs/tutorials/qcnn.ipynb +++ b/docs/tutorials/qcnn.ipynb @@ -93,74 +93,68 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "Aquwcz-0aHqz", - "vscode": { - "languageId": "python" - } - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "!pip install tensorflow==2.15.0" + "Install TensorFlow and TensorFlow Quantum:" ] }, { - "cell_type": "markdown", - "metadata": { - "colab_type": "text", - "id": "e_ZuLN_N8yhT" - }, + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ - "Install TensorFlow Quantum:" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "3Pl5PW-ACO9J", - "vscode": { - "languageId": "python" - } - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow-quantum==0.7.3" + "!pip install tensorflow-quantum==0.7.4" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J", - "vscode": { - "languageId": "python" - } - }, + "metadata": {}, "outputs": [], "source": [ "# Update package resources to account for version changes.\n", "import importlib, pkg_resources\n", - "\n", "importlib.reload(pkg_resources)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configure the use of Keras 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" + ] + }, { "cell_type": "markdown", "metadata": { "colab_type": "text", - "id": "TL_LvHXzPNjW" + "id": "F1L8h1YKUvIO" }, "source": [ - "Now import TensorFlow and the module dependencies:" + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" ] }, { @@ -1206,11 +1200,23 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 4 } diff --git a/docs/tutorials/quantum_data.ipynb b/docs/tutorials/quantum_data.ipynb index 727f9384e..0252bc203 100644 --- a/docs/tutorials/quantum_data.ipynb +++ b/docs/tutorials/quantum_data.ipynb @@ -89,47 +89,71 @@ "## Setup" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Install TensorFlow and TensorFlow Quantum:" + ] + }, { "cell_type": "code", - "execution_count": 2, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "X3Y5vLL9K_Ai", - "outputId": "60d15a69-5a45-449f-bf63-29a5af8d8ffc" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.\r\n", - "Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.\r\n", - "To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.\r\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ - "!pip install tensorflow==2.15.0 tensorflow-quantum==0.7.3" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J" - }, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install tensorflow-quantum==0.7.4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "# Update package resources to account for version changes.\n", "import importlib, pkg_resources\n", - "\n", "importlib.reload(pkg_resources)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configure the use of Keras 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "F1L8h1YKUvIO" + }, + "source": [ + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" + ] + }, { "cell_type": "code", "execution_count": 3, @@ -1124,7 +1148,7 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1138,9 +1162,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.11.9" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/docs/tutorials/quantum_reinforcement_learning.ipynb b/docs/tutorials/quantum_reinforcement_learning.ipynb index caf09c8fe..3225bab4e 100644 --- a/docs/tutorials/quantum_reinforcement_learning.ipynb +++ b/docs/tutorials/quantum_reinforcement_learning.ipynb @@ -108,42 +108,57 @@ }, { "cell_type": "markdown", - "metadata": { - "id": "pgTTkiY0wpUG" - }, + "metadata": {}, "source": [ - "Install TensorFlow:" + "Install TensorFlow and TensorFlow Quantum:" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "id": "bPTH8ScrwpUG" - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow==2.15.0" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install tensorflow-quantum==0.7.4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Update package resources to account for version changes.\n", + "import importlib, pkg_resources\n", + "importlib.reload(pkg_resources)" ] }, { "cell_type": "markdown", - "metadata": { - "id": "jlbSE9jXwpUH" - }, + "metadata": {}, "source": [ - "Install TensorFlow Quantum:" + "Configure the use of Keras 2:" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "id": "MZeJimx6wpUI" - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow-quantum==0.7.3" + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" ] }, { @@ -169,26 +184,11 @@ { "cell_type": "markdown", "metadata": { - "id": "Id8vB7FiwpUJ" + "colab_type": "text", + "id": "F1L8h1YKUvIO" }, "source": [ - "Now import TensorFlow and the module dependencies:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J" - }, - "outputs": [], - "source": [ - "# Update package resources to account for version changes.\n", - "import importlib, pkg_resources\n", - "\n", - "importlib.reload(pkg_resources)" + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" ] }, { @@ -1610,7 +1610,7 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1624,7 +1624,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9 (main, Dec 7 2022, 13:47:07) [GCC 12.2.0]" + "version": "3.11.9" }, "vscode": { "interpreter": { @@ -1633,5 +1633,5 @@ } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/docs/tutorials/research_tools.ipynb b/docs/tutorials/research_tools.ipynb index e388e0f9a..94ae06e93 100644 --- a/docs/tutorials/research_tools.ipynb +++ b/docs/tutorials/research_tools.ipynb @@ -75,33 +75,89 @@ "3. Benchmark the experiment by exploring the compute graph." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Setup" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Install TensorFlow and TensorFlow Quantum:" + ] + }, { "cell_type": "code", "execution_count": null, - "metadata": { - "id": "yZvic4nmOH7v" - }, + "metadata": {}, "outputs": [], "source": [ - "!pip install tensorflow==2.15.0 tensorflow-quantum==0.7.3 tensorboard_plugin_profile==2.15.0" + "# In Colab, you will be asked to restart the session after this finishes.\n", + "!pip install tensorflow==2.16.2" ] }, { "cell_type": "code", - "execution_count": 0, - "metadata": { - "colab": {}, - "colab_type": "code", - "id": "4Ql5PW-ACO0J" - }, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install tensorflow-quantum==0.7.4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "# Update package resources to account for version changes.\n", "import importlib, pkg_resources\n", - "\n", "importlib.reload(pkg_resources)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configure the use of Keras 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n", + "import os\n", + "os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "F1L8h1YKUvIO" + }, + "source": [ + "Install TensorBoard:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "yZvic4nmOH7v" + }, + "outputs": [], + "source": [ + "!pip install tensorboard_plugin_profile==2.15.0" + ] + }, { "cell_type": "code", "execution_count": null, @@ -114,6 +170,16 @@ "%load_ext tensorboard" ] }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "F1L8h1YKUvIO" + }, + "source": [ + "Now import TensorFlow, TensorFlow Quantum, and other modules needed:" + ] + }, { "cell_type": "code", "execution_count": null, @@ -982,7 +1048,7 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -996,9 +1062,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.11.9" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 }./configure.sh-bazel build -c opt --cxxopt="-O3" --cxxopt="-march=native" --cxxopt="-std=c++17" --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" release:build_pip_packagebazel-bin/release/build_pip_package /tmp/tfquantum/-python3 -m pip install /tmp/tfquantum/name_of_generated_wheel.whl+pip install /tmp/tfquantum/name_of_generated_wheel.whl