Skip to content

Commit 70b3118

Browse files
authored
Update tutorials to revise the pip installation command for TFQ 0.7.5 and also avoid a couple of problems (#949)
Changes: * Update the `!pip install` command in all the tutorials in `docs/tutorials/` to use `pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5`. * Add a pip install of the Python package seaborn to the the MNIST tutorial. The tutorial imports `seaborn`, but does not install it. Seaborn seems to come preinstalled in Colab and the DevSite toolchain, but someone running the notebook outside of those environments may hit a "module not found" error. By running a `!pip install seaborn` after installing TF and TFQ, we can not only save users the annoyance; we can also save future TFQ maintainers the time to debug the problem if they encounter the missing module during local testing. * Pin the version of the Gym package installed in `docs/tutorials/quantum_reinforcement_learning.ipynb`. Previously, the tutorial simply did a `!pip install gym` without a version constraint. Versions higher than 0.24.1 are incompatible some code in that tutorial (at least in TFQ 0.7.5), leading to an error during execution in some environments. Version 0.24.1 is what is installed by `scripts/ci_validate_tutorials.sh`; that's how I found the right version to make things work.
1 parent fa4b960 commit 70b3118

9 files changed

Lines changed: 12 additions & 83 deletions

docs/tutorials/barren_plateaus.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,7 @@
101101
"outputs": [],
102102
"source": [
103103
"# In Colab, you will be asked to restart the session after this finishes.\n",
104-
"!pip install tensorflow==2.16.2"
105-
]
106-
},
107-
{
108-
"cell_type": "code",
109-
"execution_count": null,
110-
"metadata": {},
111-
"outputs": [],
112-
"source": [
113-
"!pip install tensorflow-quantum==0.7.4"
104+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
114105
]
115106
},
116107
{

docs/tutorials/gradients.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,7 @@
103103
"outputs": [],
104104
"source": [
105105
"# In Colab, you will be asked to restart the session after this finishes.\n",
106-
"!pip install tensorflow==2.16.2"
107-
]
108-
},
109-
{
110-
"cell_type": "code",
111-
"execution_count": null,
112-
"metadata": {},
113-
"outputs": [],
114-
"source": [
115-
"!pip install tensorflow-quantum==0.7.4"
106+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
116107
]
117108
},
118109
{

docs/tutorials/hello_many_worlds.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,7 @@
104104
"outputs": [],
105105
"source": [
106106
"# In Colab, you will be asked to restart the session after this finishes.\n",
107-
"!pip install tensorflow==2.16.2"
108-
]
109-
},
110-
{
111-
"cell_type": "code",
112-
"execution_count": null,
113-
"metadata": {},
114-
"outputs": [],
115-
"source": [
116-
"!pip install tensorflow-quantum==0.7.4"
107+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
117108
]
118109
},
119110
{

docs/tutorials/mnist.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"outputs": [],
102102
"source": [
103103
"# In Colab, you will be asked to restart the session after this finishes.\n",
104-
"!pip install tensorflow==2.16.2"
104+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
105105
]
106106
},
107107
{
@@ -110,7 +110,8 @@
110110
"metadata": {},
111111
"outputs": [],
112112
"source": [
113-
"!pip install tensorflow-quantum==0.7.4"
113+
"# Install seaborn for use later in this notebook.\n",
114+
"!pip install seaborn\n"
114115
]
115116
},
116117
{

docs/tutorials/noise.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,7 @@
8989
"outputs": [],
9090
"source": [
9191
"# In Colab, you will be asked to restart the session after this finishes.\n",
92-
"!pip install tensorflow==2.16.2"
93-
]
94-
},
95-
{
96-
"cell_type": "code",
97-
"execution_count": null,
98-
"metadata": {},
99-
"outputs": [],
100-
"source": [
101-
"!pip install tensorflow-quantum==0.7.4"
92+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
10293
]
10394
},
10495
{

docs/tutorials/qcnn.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,7 @@
106106
"outputs": [],
107107
"source": [
108108
"# In Colab, you will be asked to restart the session after this finishes.\n",
109-
"!pip install tensorflow==2.16.2"
110-
]
111-
},
112-
{
113-
"cell_type": "code",
114-
"execution_count": null,
115-
"metadata": {},
116-
"outputs": [],
117-
"source": [
118-
"!pip install tensorflow-quantum==0.7.4"
109+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
119110
]
120111
},
121112
{

docs/tutorials/quantum_data.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,7 @@
103103
"outputs": [],
104104
"source": [
105105
"# In Colab, you will be asked to restart the session after this finishes.\n",
106-
"!pip install tensorflow==2.16.2"
107-
]
108-
},
109-
{
110-
"cell_type": "code",
111-
"execution_count": null,
112-
"metadata": {},
113-
"outputs": [],
114-
"source": [
115-
"!pip install tensorflow-quantum==0.7.4"
106+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
116107
]
117108
},
118109
{

docs/tutorials/quantum_reinforcement_learning.ipynb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,7 @@
120120
"outputs": [],
121121
"source": [
122122
"# In Colab, you will be asked to restart the session after this finishes.\n",
123-
"!pip install tensorflow==2.16.2"
124-
]
125-
},
126-
{
127-
"cell_type": "code",
128-
"execution_count": null,
129-
"metadata": {},
130-
"outputs": [],
131-
"source": [
132-
"!pip install tensorflow-quantum==0.7.4"
123+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
133124
]
134125
},
135126
{
@@ -178,7 +169,7 @@
178169
},
179170
"outputs": [],
180171
"source": [
181-
"!pip install gym"
172+
"!pip install gym==0.24.1"
182173
]
183174
},
184175
{

docs/tutorials/research_tools.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,7 @@
9696
"outputs": [],
9797
"source": [
9898
"# In Colab, you will be asked to restart the session after this finishes.\n",
99-
"!pip install tensorflow==2.16.2"
100-
]
101-
},
102-
{
103-
"cell_type": "code",
104-
"execution_count": null,
105-
"metadata": {},
106-
"outputs": [],
107-
"source": [
108-
"!pip install tensorflow-quantum==0.7.4"
99+
"!pip install tensorflow==2.16.2 tensorflow-quantum==0.7.5"
109100
]
110101
},
111102
{

0 commit comments

Comments
 (0)