Skip to content

Commit dd341a9

Browse files
committed
Simplifying plt.subplot() and adding back rows, columns, and n variables
1 parent 3581961 commit dd341a9

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

site/en/tutorials/audio/simple_audio.ipynb

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
{
1313
"cell_type": "code",
14-
"execution_count": null,
14+
"execution_count": 1,
1515
"metadata": {
1616
"cellView": "form",
1717
"id": "AJs7HHFmg1M9"
@@ -104,11 +104,26 @@
104104
},
105105
{
106106
"cell_type": "code",
107-
"execution_count": null,
107+
"execution_count": 2,
108108
"metadata": {
109109
"id": "dzLKpmZICaWN"
110110
},
111-
"outputs": [],
111+
"outputs": [
112+
{
113+
"name": "stderr",
114+
"output_type": "stream",
115+
"text": [
116+
"2023-02-21 23:30:16.927226: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX512F AVX512_VNNI FMA\n",
117+
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
118+
"2023-02-21 23:30:22.964311: I tensorflow/core/util/port.cc:104] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n",
119+
"2023-02-21 23:30:25.215418: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory\n",
120+
"2023-02-21 23:30:25.215454: I tensorflow/compiler/xla/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.\n",
121+
"2023-02-21 23:30:46.622463: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory\n",
122+
"2023-02-21 23:30:46.622808: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory\n",
123+
"2023-02-21 23:30:46.622837: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.\n"
124+
]
125+
}
126+
],
112127
"source": [
113128
"import os\n",
114129
"import pathlib\n",
@@ -143,11 +158,29 @@
143158
},
144159
{
145160
"cell_type": "code",
146-
"execution_count": null,
161+
"execution_count": 3,
147162
"metadata": {
148163
"id": "2-rayb7-3Y0I"
149164
},
150-
"outputs": [],
165+
"outputs": [
166+
{
167+
"name": "stdout",
168+
"output_type": "stream",
169+
"text": [
170+
"Downloading data from http://storage.googleapis.com/download.tensorflow.org/data/mini_speech_commands.zip\n",
171+
"112967680/182082353 [=================>............] - ETA: 1:08"
172+
]
173+
},
174+
{
175+
"name": "stderr",
176+
"output_type": "stream",
177+
"text": [
178+
"\n",
179+
"KeyboardInterrupt\n",
180+
"\n"
181+
]
182+
}
183+
],
151184
"source": [
152185
"DATASET_PATH = 'data/mini_speech_commands'\n",
153186
"\n",
@@ -322,14 +355,17 @@
322355
},
323356
"outputs": [],
324357
"source": [
325-
"plt.figure(figsize=(16,10))\n",
326-
"for i in range(9):\n",
327-
" plt.subplot(3,3,i+1)\n",
328-
" audio_signal = example_audio.numpy()[i]\n",
358+
"plt.figure(figsize=(16, 10))\n",
359+
"rows = 3\n",
360+
"cols = 3\n",
361+
"n = rows * cols\n",
362+
"for i in range(n):\n",
363+
" plt.subplot(3, 3, i+1)\n",
364+
" audio_signal = example_audio[i]\n",
329365
" plt.plot(audio_signal)\n",
330366
" plt.title(label_names[example_labels[i]])\n",
331367
" plt.yticks(np.arange(-1.2, 1.2, 0.2))\n",
332-
" plt.ylim([-1.1,1.1])"
368+
" plt.ylim([-1.1, 1.1])"
333369
]
334370
},
335371
{

0 commit comments

Comments
 (0)