Skip to content

Commit b6dbb2c

Browse files
authored
Update docs/tutorials (#942)
This updates the installation instructions in all the notebooks for TFQ 0.7.4.
1 parent 9bd8c52 commit b6dbb2c

File tree

9 files changed

+456
-279
lines changed

9 files changed

+456
-279
lines changed

docs/tutorials/barren_plateaus.ipynb

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -88,65 +88,68 @@
8888
]
8989
},
9090
{
91-
"cell_type": "code",
92-
"execution_count": null,
93-
"metadata": {
94-
"colab": {},
95-
"colab_type": "code",
96-
"id": "TorxE5tnkvb2"
97-
},
98-
"outputs": [],
91+
"cell_type": "markdown",
92+
"metadata": {},
9993
"source": [
100-
"!pip install tensorflow==2.15.0"
94+
"Install TensorFlow and TensorFlow Quantum:"
10195
]
10296
},
10397
{
104-
"cell_type": "markdown",
105-
"metadata": {
106-
"colab_type": "text",
107-
"id": "FxkQA6oblNqI"
108-
},
98+
"cell_type": "code",
99+
"execution_count": null,
100+
"metadata": {},
101+
"outputs": [],
109102
"source": [
110-
"Install TensorFlow Quantum:"
103+
"# In Colab, you will be asked to restart the session after this finishes.\n",
104+
"!pip install tensorflow==2.16.2"
111105
]
112106
},
113107
{
114108
"cell_type": "code",
115109
"execution_count": null,
116-
"metadata": {
117-
"colab": {},
118-
"colab_type": "code",
119-
"id": "saFHsRDpkvkH"
120-
},
110+
"metadata": {},
121111
"outputs": [],
122112
"source": [
123-
"!pip install tensorflow-quantum==0.7.3"
113+
"!pip install tensorflow-quantum==0.7.4"
124114
]
125115
},
126116
{
127117
"cell_type": "code",
128118
"execution_count": null,
129-
"metadata": {
130-
"colab": {},
131-
"colab_type": "code",
132-
"id": "4Ql5PW-ACO0J"
133-
},
119+
"metadata": {},
134120
"outputs": [],
135121
"source": [
136122
"# Update package resources to account for version changes.\n",
137123
"import importlib, pkg_resources\n",
138-
"\n",
139124
"importlib.reload(pkg_resources)"
140125
]
141126
},
127+
{
128+
"cell_type": "markdown",
129+
"metadata": {},
130+
"source": [
131+
"Configure the use of Keras 2:"
132+
]
133+
},
134+
{
135+
"cell_type": "code",
136+
"execution_count": null,
137+
"metadata": {},
138+
"outputs": [],
139+
"source": [
140+
"# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n",
141+
"import os\n",
142+
"os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\""
143+
]
144+
},
142145
{
143146
"cell_type": "markdown",
144147
"metadata": {
145148
"colab_type": "text",
146-
"id": "1PaclXeSrrMW"
149+
"id": "F1L8h1YKUvIO"
147150
},
148151
"source": [
149-
"Now import TensorFlow and the module dependencies:"
152+
"Now import TensorFlow, TensorFlow Quantum, and other modules needed:"
150153
]
151154
},
152155
{
@@ -509,13 +512,21 @@
509512
"toc_visible": true
510513
},
511514
"kernelspec": {
512-
"display_name": "Python 3",
515+
"display_name": "Python 3 (ipykernel)",
513516
"language": "python",
514517
"name": "python3"
515518
},
516519
"language_info": {
520+
"codemirror_mode": {
521+
"name": "ipython",
522+
"version": 3
523+
},
524+
"file_extension": ".py",
525+
"mimetype": "text/x-python",
517526
"name": "python",
518-
"version": "3.10.9 (main, Dec 7 2022, 13:47:07) [GCC 12.2.0]"
527+
"nbconvert_exporter": "python",
528+
"pygments_lexer": "ipython3",
529+
"version": "3.11.9"
519530
},
520531
"vscode": {
521532
"interpreter": {
@@ -524,5 +535,5 @@
524535
}
525536
},
526537
"nbformat": 4,
527-
"nbformat_minor": 0
538+
"nbformat_minor": 4
528539
}

docs/tutorials/gradients.ipynb

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,65 +90,68 @@
9090
]
9191
},
9292
{
93-
"cell_type": "code",
94-
"execution_count": null,
95-
"metadata": {
96-
"colab": {},
97-
"colab_type": "code",
98-
"id": "TorxE5tnkvb2"
99-
},
100-
"outputs": [],
93+
"cell_type": "markdown",
94+
"metadata": {},
10195
"source": [
102-
"!pip install tensorflow==2.15.0"
96+
"Install TensorFlow and TensorFlow Quantum:"
10397
]
10498
},
10599
{
106-
"cell_type": "markdown",
107-
"metadata": {
108-
"colab_type": "text",
109-
"id": "OIbP5hklC338"
110-
},
100+
"cell_type": "code",
101+
"execution_count": null,
102+
"metadata": {},
103+
"outputs": [],
111104
"source": [
112-
"Install TensorFlow Quantum:"
105+
"# In Colab, you will be asked to restart the session after this finishes.\n",
106+
"!pip install tensorflow==2.16.2"
113107
]
114108
},
115109
{
116110
"cell_type": "code",
117111
"execution_count": null,
118-
"metadata": {
119-
"colab": {},
120-
"colab_type": "code",
121-
"id": "saFHsRDpkvkH"
122-
},
112+
"metadata": {},
123113
"outputs": [],
124114
"source": [
125-
"!pip install tensorflow-quantum==0.7.3"
115+
"!pip install tensorflow-quantum==0.7.4"
126116
]
127117
},
128118
{
129119
"cell_type": "code",
130120
"execution_count": null,
131-
"metadata": {
132-
"colab": {},
133-
"colab_type": "code",
134-
"id": "4Ql5PW-ACO0J"
135-
},
121+
"metadata": {},
136122
"outputs": [],
137123
"source": [
138124
"# Update package resources to account for version changes.\n",
139125
"import importlib, pkg_resources\n",
140-
"\n",
141126
"importlib.reload(pkg_resources)"
142127
]
143128
},
129+
{
130+
"cell_type": "markdown",
131+
"metadata": {},
132+
"source": [
133+
"Configure the use of Keras 2:"
134+
]
135+
},
136+
{
137+
"cell_type": "code",
138+
"execution_count": null,
139+
"metadata": {},
140+
"outputs": [],
141+
"source": [
142+
"# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n",
143+
"import os\n",
144+
"os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\""
145+
]
146+
},
144147
{
145148
"cell_type": "markdown",
146149
"metadata": {
147150
"colab_type": "text",
148-
"id": "MkTqyoSxGUfB"
151+
"id": "F1L8h1YKUvIO"
149152
},
150153
"source": [
151-
"Now import TensorFlow and the module dependencies:"
154+
"Now import TensorFlow, TensorFlow Quantum, and other modules needed:"
152155
]
153156
},
154157
{
@@ -810,13 +813,21 @@
810813
"toc_visible": true
811814
},
812815
"kernelspec": {
813-
"display_name": "Python 3",
816+
"display_name": "Python 3 (ipykernel)",
814817
"language": "python",
815818
"name": "python3"
816819
},
817820
"language_info": {
821+
"codemirror_mode": {
822+
"name": "ipython",
823+
"version": 3
824+
},
825+
"file_extension": ".py",
826+
"mimetype": "text/x-python",
818827
"name": "python",
819-
"version": "3.10.9 (main, Dec 7 2022, 13:47:07) [GCC 12.2.0]"
828+
"nbconvert_exporter": "python",
829+
"pygments_lexer": "ipython3",
830+
"version": "3.11.9"
820831
},
821832
"vscode": {
822833
"interpreter": {
@@ -825,5 +836,5 @@
825836
}
826837
},
827838
"nbformat": 4,
828-
"nbformat_minor": 0
839+
"nbformat_minor": 4
829840
}

docs/tutorials/hello_many_worlds.ipynb

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -91,74 +91,68 @@
9191
]
9292
},
9393
{
94-
"cell_type": "code",
95-
"execution_count": null,
96-
"metadata": {
97-
"colab": {},
98-
"colab_type": "code",
99-
"id": "TorxE5tnkvb2",
100-
"vscode": {
101-
"languageId": "python"
102-
}
103-
},
104-
"outputs": [],
94+
"cell_type": "markdown",
95+
"metadata": {},
10596
"source": [
106-
"!pip install tensorflow==2.15.0"
97+
"Install TensorFlow and TensorFlow Quantum:"
10798
]
10899
},
109100
{
110-
"cell_type": "markdown",
111-
"metadata": {
112-
"colab_type": "text",
113-
"id": "FxkQA6oblNqI"
114-
},
101+
"cell_type": "code",
102+
"execution_count": null,
103+
"metadata": {},
104+
"outputs": [],
115105
"source": [
116-
"Install TensorFlow Quantum:"
106+
"# In Colab, you will be asked to restart the session after this finishes.\n",
107+
"!pip install tensorflow==2.16.2"
117108
]
118109
},
119110
{
120111
"cell_type": "code",
121112
"execution_count": null,
122-
"metadata": {
123-
"colab": {},
124-
"colab_type": "code",
125-
"id": "saFHsRDpkvkH",
126-
"vscode": {
127-
"languageId": "python"
128-
}
129-
},
113+
"metadata": {},
130114
"outputs": [],
131115
"source": [
132-
"!pip install tensorflow-quantum==0.7.3"
116+
"!pip install tensorflow-quantum==0.7.4"
133117
]
134118
},
135119
{
136120
"cell_type": "code",
137121
"execution_count": null,
138-
"metadata": {
139-
"colab": {},
140-
"colab_type": "code",
141-
"id": "4Ql5PW-ACO0J",
142-
"vscode": {
143-
"languageId": "python"
144-
}
145-
},
122+
"metadata": {},
146123
"outputs": [],
147124
"source": [
148125
"# Update package resources to account for version changes.\n",
149126
"import importlib, pkg_resources\n",
150-
"\n",
151127
"importlib.reload(pkg_resources)"
152128
]
153129
},
130+
{
131+
"cell_type": "markdown",
132+
"metadata": {},
133+
"source": [
134+
"Configure the use of Keras 2:"
135+
]
136+
},
137+
{
138+
"cell_type": "code",
139+
"execution_count": null,
140+
"metadata": {},
141+
"outputs": [],
142+
"source": [
143+
"# Keras 2 must be selected before importing TensorFlow or TensorFlow Quantum:\n",
144+
"import os\n",
145+
"os.environ[\"TF_USE_LEGACY_KERAS\"] = \"1\""
146+
]
147+
},
154148
{
155149
"cell_type": "markdown",
156150
"metadata": {
157151
"colab_type": "text",
158152
"id": "F1L8h1YKUvIO"
159153
},
160154
"source": [
161-
"Now import TensorFlow and the module dependencies:"
155+
"Now import TensorFlow, TensorFlow Quantum, and other modules needed:"
162156
]
163157
},
164158
{
@@ -794,7 +788,7 @@
794788
"id": "yJSC9qH76pJA"
795789
},
796790
"source": [
797-
"The model attempts to output the correct correct measurement value of $\\hat{Z}$ for each command. The commands and correct values are defined below."
791+
"The model attempts to output the correct measurement value of $\\hat{Z}$ for each command. The commands and correct values are defined below."
798792
]
799793
},
800794
{
@@ -1333,11 +1327,23 @@
13331327
"toc_visible": true
13341328
},
13351329
"kernelspec": {
1336-
"display_name": "Python 3",
1330+
"display_name": "Python 3 (ipykernel)",
13371331
"language": "python",
13381332
"name": "python3"
1333+
},
1334+
"language_info": {
1335+
"codemirror_mode": {
1336+
"name": "ipython",
1337+
"version": 3
1338+
},
1339+
"file_extension": ".py",
1340+
"mimetype": "text/x-python",
1341+
"name": "python",
1342+
"nbconvert_exporter": "python",
1343+
"pygments_lexer": "ipython3",
1344+
"version": "3.11.9"
13391345
}
13401346
},
13411347
"nbformat": 4,
1342-
"nbformat_minor": 0
1348+
"nbformat_minor": 4
13431349
}

0 commit comments

Comments
 (0)