Skip to content

Commit 786fe1a

Browse files
Johannes Ballécopybara-github
authored andcommitted
Reformats Colab notebooks.
PiperOrigin-RevId: 479436208 Change-Id: I0d2a7feceb346039af1974ff3418c80ef7d980c5
1 parent cc191bb commit 786fe1a

File tree

2 files changed

+24
-50
lines changed

2 files changed

+24
-50
lines changed

models/hific/colab.ipynb

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,16 @@
112112
"File = collections.namedtuple('File', ['full_path', 'num_bytes', 'bpp'])\n",
113113
"\n",
114114
"def print_html(html):\n",
115-
" display(HTML(html + '\u003cbr/\u003e'))\n",
115+
" display(HTML(html + '<br/>'))\n",
116116
"\n",
117117
"def make_cell_large():\n",
118118
" display(Javascript(\n",
119119
" '''google.colab.output.setIframeHeight(0, true, {maxHeight: 5000})'''))\n",
120120
"\n",
121121
"def get_default_image(output_dir):\n",
122122
" output_path = os.path.join(output_dir, os.path.basename(DEFAULT_IMAGE_URL))\n",
123-
" print('Downloading', DEFAULT_IMAGE_URL, '\\n-\u003e', output_path)\n",
124-
" urllib.request.urlretrieve(DEFAULT_IMAGE_URL, output_path)\n",
125-
"\n"
123+
" print('Downloading', DEFAULT_IMAGE_URL, '\\n->', output_path)\n",
124+
" urllib.request.urlretrieve(DEFAULT_IMAGE_URL, output_path)\n"
126125
]
127126
},
128127
{
@@ -162,8 +161,7 @@
162161
"#@markdown #### Select a model\n",
163162
"#@markdown Different models target different bitrates.\n",
164163
"\n",
165-
"model = 'hific-lo' #@param [\"hific-lo\", \"hific-mi\", \"hific-hi\"]\n",
166-
"\n"
164+
"model = 'hific-lo' #@param [\"hific-lo\", \"hific-mi\", \"hific-hi\"]\n"
167165
]
168166
},
169167
{
@@ -296,10 +294,10 @@
296294
"make_cell_large() # Larger output window.\n",
297295
"\n",
298296
"for file in all_outputs:\n",
299-
" print_html('\u003chr/\u003e')\n",
297+
" print_html('<hr/>')\n",
300298
" print(f'Showing {file.full_path} | {file.num_bytes//1000}kB | {file.bpp:.4f}bpp')\n",
301299
" display(Image.open(file.full_path))\n",
302-
" print_html('\u003chr/\u003e')"
300+
" print_html('<hr/>')"
303301
]
304302
},
305303
{
@@ -342,17 +340,7 @@
342340
"accelerator": "GPU",
343341
"colab": {
344342
"collapsed_sections": [],
345-
"last_runtime": {
346-
"build_target": "//research/colab/notebook:notebook_backend_py3",
347-
"kind": "private"
348-
},
349-
"name": "HiFiC_Interactive_Colab.ipynb",
350-
"provenance": [
351-
{
352-
353-
"timestamp": 1615973093906
354-
}
355-
],
343+
"name": "colab.ipynb",
356344
"toc_visible": true
357345
},
358346
"kernelspec": {

models/toy_sources/toy_sources.ipynb

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,27 @@
1212
"\n",
1313
"The Laplace and Banana sources are described in:\n",
1414
"\n",
15-
"\u003e \"Nonlinear Transform Coding\"\u003cbr /\u003e\n",
16-
"\u003e J. Ballé, P. A. Chou, D. Minnen, S. Singh, N. Johnston, E. Agustsson, S. J. Hwang, G. Toderici\u003cbr /\u003e\n",
17-
"\u003e https://arxiv.org/abs/2007.03034\n",
15+
"> \"Nonlinear Transform Coding\"<br />\n",
16+
"> J. Ballé, P. A. Chou, D. Minnen, S. Singh, N. Johnston, E. Agustsson, S. J. Hwang, G. Toderici<br />\n",
17+
"> https://arxiv.org/abs/2007.03034\n",
1818
"\n",
1919
"The Sawbridge process is described in:\n",
2020
"\n",
21-
"\u003e \"Neural Networks Optimally Compress the Sawbridge\"\u003cbr /\u003e\n",
22-
"\u003e A. B. Wagner, J. Ballé\u003cbr /\u003e\n",
23-
"\u003e https://arxiv.org/abs/2011.05065\n",
21+
"> \"Neural Networks Optimally Compress the Sawbridge\"<br />\n",
22+
"> A. B. Wagner, J. Ballé<br />\n",
23+
"> https://arxiv.org/abs/2011.05065\n",
2424
"\n",
2525
"This notebook requires TFC v2 (`pip install tensorflow-compression==2.*`)\n"
2626
]
2727
},
2828
{
2929
"cell_type": "code",
30+
"execution_count": null,
3031
"metadata": {
3132
"cellView": "form",
3233
"id": "wdA5NUZ-fSxG"
3334
},
35+
"outputs": [],
3436
"source": [
3537
"#@title Dependencies for Colab\n",
3638
"\n",
@@ -43,9 +45,7 @@
4345
"# Downloads the 'models' directory from Github.\n",
4446
"![[ -e /tfc ]] || git clone https://github.com/tensorflow/compression /tfc\n",
4547
"%cd /tfc/models\n"
46-
],
47-
"execution_count": null,
48-
"outputs": []
48+
]
4949
},
5050
{
5151
"cell_type": "code",
@@ -322,7 +322,7 @@
322322
" # Estimate KLT from samples.\n",
323323
" eigv, error = estimate_klt(\n",
324324
" source, tf.constant(num_samples), tf.constant(latent_dims))\n",
325-
" assert error \u003c tolerance, error.numpy()\n",
325+
" assert error < tolerance, error.numpy()\n",
326326
" eigv = tf.cast(eigv, dtype)\n",
327327
"\n",
328328
" analysis = tf.keras.Sequential([\n",
@@ -417,13 +417,13 @@
417417
" \"\"\"Returns a learning rate scheduler function for the given configuration.\"\"\"\n",
418418
" def scheduler(epoch, lr):\n",
419419
" del lr # unused\n",
420-
" if epoch \u003c warmup_epochs:\n",
420+
" if epoch < warmup_epochs:\n",
421421
" return learning_rate * 10. ** (epoch - warmup_epochs)\n",
422-
" if epoch \u003c 1/2 * epochs:\n",
422+
" if epoch < 1/2 * epochs:\n",
423423
" return learning_rate\n",
424-
" if epoch \u003c 3/4 * epochs:\n",
424+
" if epoch < 3/4 * epochs:\n",
425425
" return learning_rate * 1e-1\n",
426-
" if epoch \u003c 7/8 * epochs:\n",
426+
" if epoch < 7/8 * epochs:\n",
427427
" return learning_rate * 1e-2\n",
428428
" return learning_rate * 1e-3\n",
429429
" return scheduler\n",
@@ -456,7 +456,7 @@
456456
"def get_alpha_scheduler(epochs):\n",
457457
" \"\"\"Returns an alpha scheduler function for the given configuration.\"\"\"\n",
458458
" def scheduler(epoch):\n",
459-
" if epoch \u003c 1/4 * epochs:\n",
459+
" if epoch < 1/4 * epochs:\n",
460460
" return 3. * (epoch + 1) / (epochs/4 + 1)\n",
461461
" return None\n",
462462
" return scheduler\n"
@@ -1160,17 +1160,6 @@
11601160
" callbacks=tf.keras.callbacks.CallbackList(callback_list, model=model),\n",
11611161
")\n"
11621162
]
1163-
},
1164-
{
1165-
"cell_type": "code",
1166-
"execution_count": null,
1167-
"metadata": {
1168-
"id": "TmK8AWxQRl6E"
1169-
},
1170-
"outputs": [],
1171-
"source": [
1172-
""
1173-
]
11741163
}
11751164
],
11761165
"metadata": {
@@ -1180,11 +1169,8 @@
11801169
"cVgn8T6pySgP",
11811170
"KmoKt709KFAv"
11821171
],
1183-
"last_runtime": {
1184-
"build_target": "",
1185-
"kind": "local"
1186-
},
1187-
"name": "toy_sources.ipynb"
1172+
"name": "toy_sources.ipynb",
1173+
"toc_visible": true
11881174
},
11891175
"kernelspec": {
11901176
"display_name": "Python 3",

0 commit comments

Comments
 (0)