Skip to content

Commit 7f89ec9

Browse files
committed
Colab formatting
1 parent 286b5e8 commit 7f89ec9

File tree

1 file changed

+73
-69
lines changed

1 file changed

+73
-69
lines changed

site/ko/tutorials/distribute/multi_worker_with_keras.ipynb

Lines changed: 73 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"name": "multi_worker_with_keras.ipynb",
7+
"version": "0.3.2",
8+
"provenance": [],
9+
"private_outputs": true,
10+
"collapsed_sections": [],
11+
"toc_visible": true
12+
},
13+
"kernelspec": {
14+
"display_name": "Python 3",
15+
"name": "python3"
16+
}
17+
},
218
"cells": [
319
{
420
"cell_type": "markdown",
@@ -13,13 +29,12 @@
1329
},
1430
{
1531
"cell_type": "code",
16-
"execution_count": 0,
1732
"metadata": {
18-
"colab": {},
1933
"colab_type": "code",
20-
"id": "tuOe1ymfHZPu"
34+
"id": "tuOe1ymfHZPu",
35+
"colab": {},
36+
"cellView": "form"
2137
},
22-
"outputs": [],
2338
"source": [
2439
"#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
2540
"# you may not use this file except in compliance with the License.\n",
@@ -32,7 +47,9 @@
3247
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
3348
"# See the License for the specific language governing permissions and\n",
3449
"# limitations under the License."
35-
]
50+
],
51+
"execution_count": 0,
52+
"outputs": []
3653
},
3754
{
3855
"cell_type": "markdown",
@@ -58,7 +75,10 @@
5875
},
5976
{
6077
"cell_type": "markdown",
61-
"metadata": {},
78+
"metadata": {
79+
"id": "FcjoxbKVT3r-",
80+
"colab_type": "text"
81+
},
6282
"source": [
6383
"Note: 이 문서는 텐서플로 커뮤니티에서 번역했습니다. 커뮤니티 번역 활동의 특성상 정확한 번역과 최신 내용을 반영하기 위해 노력함에도 불구하고 [공식 영문 문서](https://github.com/tensorflow/docs/blob/master/site/en/tutorials/distribute/multi_worker_with_keras.ipynb)의 내용과 일치하지 않을 수 있습니다. 이 번역에 개선할 부분이 있다면 [tensorflow/docs](https://github.com/tensorflow/docs) 깃허브 저장소로 풀 리퀘스트를 보내주시기 바랍니다. 문서 번역이나 리뷰에 참여하려면 [docs-ko@tensorflow.org](https://groups.google.com/a/tensorflow.org/forum/#!forum/docs-ko)로 메일을 보내주시기 바랍니다."
6484
]
@@ -91,26 +111,24 @@
91111
},
92112
{
93113
"cell_type": "code",
94-
"execution_count": 0,
95114
"metadata": {
96-
"colab": {},
97115
"colab_type": "code",
98-
"id": "IqR2PQG4ZaZ0"
116+
"id": "IqR2PQG4ZaZ0",
117+
"colab": {}
99118
},
100-
"outputs": [],
101119
"source": [
102120
"from __future__ import absolute_import, division, print_function, unicode_literals"
103-
]
121+
],
122+
"execution_count": 0,
123+
"outputs": []
104124
},
105125
{
106126
"cell_type": "code",
107-
"execution_count": 0,
108127
"metadata": {
109-
"colab": {},
110128
"colab_type": "code",
111-
"id": "bnYxvfLD-LW-"
129+
"id": "bnYxvfLD-LW-",
130+
"colab": {}
112131
},
113-
"outputs": [],
114132
"source": [
115133
"try:\n",
116134
" # %tensorflow_version 기능은 코랩에서만 사용할 수 있습니다.\n",
@@ -120,7 +138,9 @@
120138
"import tensorflow_datasets as tfds\n",
121139
"import tensorflow as tf\n",
122140
"tfds.disable_progress_bar()"
123-
]
141+
],
142+
"execution_count": 0,
143+
"outputs": []
124144
},
125145
{
126146
"cell_type": "markdown",
@@ -136,13 +156,11 @@
136156
},
137157
{
138158
"cell_type": "code",
139-
"execution_count": 0,
140159
"metadata": {
141-
"colab": {},
142160
"colab_type": "code",
143-
"id": "dma_wUAxZqo2"
161+
"id": "dma_wUAxZqo2",
162+
"colab": {}
144163
},
145-
"outputs": [],
146164
"source": [
147165
"BUFFER_SIZE = 10000\n",
148166
"BATCH_SIZE = 64\n",
@@ -159,7 +177,9 @@
159177
"\n",
160178
"train_datasets_unbatched = datasets['train'].map(scale).cache().shuffle(BUFFER_SIZE)\n",
161179
"train_datasets = train_datasets_unbatched.batch(BATCH_SIZE)"
162-
]
180+
],
181+
"execution_count": 0,
182+
"outputs": []
163183
},
164184
{
165185
"cell_type": "markdown",
@@ -176,13 +196,11 @@
176196
},
177197
{
178198
"cell_type": "code",
179-
"execution_count": 0,
180199
"metadata": {
181-
"colab": {},
182200
"colab_type": "code",
183-
"id": "aVPHl0SfG2v1"
201+
"id": "aVPHl0SfG2v1",
202+
"colab": {}
184203
},
185-
"outputs": [],
186204
"source": [
187205
"def build_and_compile_cnn_model():\n",
188206
" model = tf.keras.Sequential([\n",
@@ -197,7 +215,9 @@
197215
" optimizer=tf.keras.optimizers.SGD(learning_rate=0.001),\n",
198216
" metrics=['accuracy'])\n",
199217
" return model"
200-
]
218+
],
219+
"execution_count": 0,
220+
"outputs": []
201221
},
202222
{
203223
"cell_type": "markdown",
@@ -211,17 +231,17 @@
211231
},
212232
{
213233
"cell_type": "code",
214-
"execution_count": 0,
215234
"metadata": {
216-
"colab": {},
217235
"colab_type": "code",
218-
"id": "6Qe6iAf5O8iJ"
236+
"id": "6Qe6iAf5O8iJ",
237+
"colab": {}
219238
},
220-
"outputs": [],
221239
"source": [
222240
"single_worker_model = build_and_compile_cnn_model()\n",
223241
"single_worker_model.fit(x=train_datasets, epochs=3)"
224-
]
242+
],
243+
"execution_count": 0,
244+
"outputs": []
225245
},
226246
{
227247
"cell_type": "markdown",
@@ -281,16 +301,16 @@
281301
},
282302
{
283303
"cell_type": "code",
284-
"execution_count": 0,
285304
"metadata": {
286-
"colab": {},
287305
"colab_type": "code",
288-
"id": "1uFSHCJXMrQ-"
306+
"id": "1uFSHCJXMrQ-",
307+
"colab": {}
289308
},
290-
"outputs": [],
291309
"source": [
292310
"strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy()"
293-
]
311+
],
312+
"execution_count": 0,
313+
"outputs": []
294314
},
295315
{
296316
"cell_type": "markdown",
@@ -329,13 +349,11 @@
329349
},
330350
{
331351
"cell_type": "code",
332-
"execution_count": 0,
333352
"metadata": {
334-
"colab": {},
335353
"colab_type": "code",
336-
"id": "BcsuBYrpgnlS"
354+
"id": "BcsuBYrpgnlS",
355+
"colab": {}
337356
},
338-
"outputs": [],
339357
"source": [
340358
"NUM_WORKERS = 2\n",
341359
"# 여기서 배치 크기는 워커의 수를 곱한 크기로 늘려야 합니다. `tf.data.Dataset.batch`에는\n",
@@ -345,7 +363,9 @@
345363
"with strategy.scope():\n",
346364
" multi_worker_model = build_and_compile_cnn_model()\n",
347365
"multi_worker_model.fit(x=train_datasets, epochs=3)"
348-
]
366+
],
367+
"execution_count": 0,
368+
"outputs": []
349369
},
350370
{
351371
"cell_type": "markdown",
@@ -362,18 +382,18 @@
362382
},
363383
{
364384
"cell_type": "code",
365-
"execution_count": 0,
366385
"metadata": {
367-
"colab": {},
368386
"colab_type": "code",
369-
"id": "JxEtdh1vH-TF"
387+
"id": "JxEtdh1vH-TF",
388+
"colab": {}
370389
},
371-
"outputs": [],
372390
"source": [
373391
"options = tf.data.Options()\n",
374392
"options.experimental_distribute.auto_shard = False\n",
375393
"train_datasets_no_auto_shard = train_datasets.with_options(options)"
376-
]
394+
],
395+
"execution_count": 0,
396+
"outputs": []
377397
},
378398
{
379399
"cell_type": "markdown",
@@ -421,20 +441,20 @@
421441
},
422442
{
423443
"cell_type": "code",
424-
"execution_count": 0,
425444
"metadata": {
426-
"colab": {},
427445
"colab_type": "code",
428-
"id": "xIY9vKnUU82o"
446+
"id": "xIY9vKnUU82o",
447+
"colab": {}
429448
},
430-
"outputs": [],
431449
"source": [
432450
"# `filepath` 매개변수를 모든 워커가 접근할 수 있는 파일 시스템 경로로 바꾸십시오.\n",
433451
"callbacks = [tf.keras.callbacks.ModelCheckpoint(filepath='/tmp/keras-ckpt')]\n",
434452
"with strategy.scope():\n",
435453
" multi_worker_model = build_and_compile_cnn_model()\n",
436454
"multi_worker_model.fit(x=train_datasets, epochs=3, callbacks=callbacks)"
437-
]
455+
],
456+
"execution_count": 0,
457+
"outputs": []
438458
},
439459
{
440460
"cell_type": "markdown",
@@ -460,21 +480,5 @@
460480
"2. 공식 [ResNet50](https://github.com/tensorflow/models/blob/master/official/resnet/imagenet_main.py) 모델은 `MirroredStrategy`나 `MultiWorkerMirroredStrategy`로 훈련할 수 있습니다."
461481
]
462482
}
463-
],
464-
"metadata": {
465-
"colab": {
466-
"collapsed_sections": [],
467-
"name": "multi_worker_with_keras.ipynb",
468-
"private_outputs": true,
469-
"provenance": [],
470-
"toc_visible": true,
471-
"version": "0.3.2"
472-
},
473-
"kernelspec": {
474-
"display_name": "Python 3",
475-
"name": "python3"
476-
}
477-
},
478-
"nbformat": 4,
479-
"nbformat_minor": 0
480-
}
483+
]
484+
}

0 commit comments

Comments
 (0)