From ec104809ec6a42557a751d66eaae246008090eca Mon Sep 17 00:00:00 2001 From: Hyung Jin Harry Chung Date: Fri, 8 Feb 2019 01:57:03 +0900 Subject: [PATCH 1/4] =?UTF-8?q?History=EA=B9=8C=EC=A7=80=20=EB=B2=88?= =?UTF-8?q?=EC=97=AD=20=EC=B4=88=EC=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit accuracy, validation을 원문 그대로 두었습니다. --- sources/callbacks.md | 81 ++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/sources/callbacks.md b/sources/callbacks.md index e922538e..43b42fd5 100644 --- a/sources/callbacks.md +++ b/sources/callbacks.md @@ -1,6 +1,6 @@ -## Usage of callbacks +## callbacks의 용도 -A callback is a set of functions to be applied at given stages of the training procedure. You can use callbacks to get a view on internal states and statistics of the model during training. You can pass a list of callbacks (as the keyword argument `callbacks`) to the `.fit()` method of the `Sequential` or `Model` classes. The relevant methods of the callbacks will then be called at each stage of the training. +callback은 주어진 학습 단계에서 적용될 수 있는 함수들의 집합입니다. 여러분은 모델의 훈련 도중 모델 내의 상태와 통계를 보기 위해 callbacks를 이용할 수 있습니다. callbacks의 리스트(키워드 인수 'callbacks'로)를 'Sequential' 또는 'Model' 클래스의 '.fit()' 메소드에 전달할 수 있습니다. 주어진 callbacks의 메소드는 훈련의 각 단계별로 호출될 것입니다. --- @@ -11,31 +11,31 @@ A callback is a set of functions to be applied at given stages of the training p keras.callbacks.Callback() ``` -Abstract base class used to build new callbacks. +새로운 callbacks를 빌드하는데 사용되는 추상화 기초 클래스(abstract base class)입니다. __Properties__ -- __params__: dict. Training parameters - (eg. verbosity, batch size, number of epochs...). -- __model__: instance of `keras.models.Model`. - Reference of the model being trained. +- __params__: 딕셔너리. 훈련 매개변수 + (eg. 자세한 정도, 배치 크기, 에포크 수 등...). +- __model__: 'keras.models.Model'의 인스턴스. + 훈련되고 있는 모델의 기준 -The `logs` dictionary that callback methods -take as argument will contain keys for quantities relevant to -the current batch or epoch. +callbacks의 메소드들이 인수로 받아들이는 'logs' 딕셔너리는 +현재 배치, 또는 에포크에 해당하는 키 값들을 갖고 있습니다. -Currently, the `.fit()` method of the `Sequential` model class -will include the following quantities in the `logs` that -it passes to its callbacks: +지금은 'Sequential' 모델 클래스의 '.fit()' 메소드가 'logs' +에 다음과 같은 값들을 포함하고 있을것이며, 이 값들을 callbacks +에 넘깁니다.: -on_epoch_end: logs include `acc` and `loss`, and -optionally include `val_loss` -(if validation is enabled in `fit`), and `val_acc` -(if validation and accuracy monitoring are enabled). -on_batch_begin: logs include `size`, -the number of samples in the current batch. -on_batch_end: logs include `loss`, and optionally `acc` -(if accuracy monitoring is enabled). +on_epoch_end: 한 에포크가 끝날 때 logs에는 'acc' 와 'loss', +그리고 선택적으로 'val_loss'(만약 validation이 'fit'에 활성화되어있다면) +와 'val_acc'(만약 validation과 accuracy 모니터링이 활성화 되어있다면) +를 포함합니다. +on_batch_begin: 한 배치의 시작점에 logs는 현재 배치에 들어 있는 +샘플의 수인 'size'를 포함합니다. +on_batch_end: 한 배치가 끝나는 지점에 logs는 'loss'를 포함하고, +선택적으로 'acc'(만약 accuracy 모니터링이 활성화 되어있다면)를 +포함합니다. ---- @@ -45,17 +45,16 @@ on_batch_end: logs include `loss`, and optionally `acc` ```python keras.callbacks.BaseLogger(stateful_metrics=None) ``` +측정 단위의 에포크별 평균을 누적시키는 콜백 -Callback that accumulates epoch averages of metrics. - -This callback is automatically applied to every Keras model. +이 콜백은 모든 케라스 모델에 자동으로 적용됩니다. __Arguments__ -- __stateful_metrics__: Iterable of string names of metrics that - should *not* be averaged over an epoch. - Metrics in this list will be logged as-is in `on_epoch_end`. - All others will be averaged in `on_epoch_end`. +- __stateful_metrics__: 에포크 단위별로 평균을 취하지 *말아야* 할 + 반복될 수 있는 측정 단위의 이름(스트링) + 이 리스트에 해당하는 측정 단위들은 'on_epoch_end' log에 값 그대로 + 포함 되며, 다른 측정 단위들은 'on_epoch_end'에 평균되어 들어갑니다. ---- @@ -66,6 +65,7 @@ __Arguments__ keras.callbacks.TerminateOnNaN() ``` +훈련 도중 loss 값이 NaN이 나왔을 때 종결시키는 콜백. Callback that terminates training when a NaN loss is encountered. ---- @@ -77,21 +77,20 @@ Callback that terminates training when a NaN loss is encountered. keras.callbacks.ProgbarLogger(count_mode='samples', stateful_metrics=None) ``` -Callback that prints metrics to stdout. +stdout 에 측정단위들을 프린트하는 콜백 __Arguments__ -- __count_mode__: One of "steps" or "samples". - Whether the progress bar should - count samples seen or steps (batches) seen. -- __stateful_metrics__: Iterable of string names of metrics that - should *not* be averaged over an epoch. - Metrics in this list will be logged as-is. - All others will be averaged over time (e.g. loss, etc). +- __count_mode__: "steps"나 "samples"중 하나. + 진행 표시줄이 샘플 갯수를 셀 지 배치 단계를 셀 지 정해줍니다. +- __stateful_metrics__: 에포크 단위별로 평균을 취하지 *말아야* 할 + 반복될 수 있는 측정 단위의 이름(스트링) + 이 리스트에 해당하는 측정 단위들은 값 그대로 + 포함 되며, 다른 측정 단위들은 평균되어 들어갑니다.(eg. loss, etc..) __Raises__ -- __ValueError__: In case of invalid `count_mode`. +- __ValueError__: 적절치 않은 'count_mode'가 주어졌을 때. ---- @@ -102,11 +101,11 @@ __Raises__ keras.callbacks.History() ``` -Callback that records events into a `History` object. +'History' 오브젝트에 이벤트를 기록하는 콜백. -This callback is automatically applied to -every Keras model. The `History` object -gets returned by the `fit` method of models. +이 콜백은 모든 케라스 모델에 자동적으로 적용됩니다. +'History' 오브젝트는 모델의 'fit' 메소드에 의해 +반환됩니다. ---- From cb70563a30df411737d95a4daa2b651091c3c7b3 Mon Sep 17 00:00:00 2001 From: Hyung Jin Harry Chung Date: Fri, 8 Feb 2019 16:13:46 +0900 Subject: [PATCH 2/4] =?UTF-8?q?RemoteMonitor=EA=B9=8C=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/callbacks.md | 102 ++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 55 deletions(-) diff --git a/sources/callbacks.md b/sources/callbacks.md index 43b42fd5..a3172a87 100644 --- a/sources/callbacks.md +++ b/sources/callbacks.md @@ -1,6 +1,6 @@ ## callbacks의 용도 -callback은 주어진 학습 단계에서 적용될 수 있는 함수들의 집합입니다. 여러분은 모델의 훈련 도중 모델 내의 상태와 통계를 보기 위해 callbacks를 이용할 수 있습니다. callbacks의 리스트(키워드 인수 'callbacks'로)를 'Sequential' 또는 'Model' 클래스의 '.fit()' 메소드에 전달할 수 있습니다. 주어진 callbacks의 메소드는 훈련의 각 단계별로 호출될 것입니다. +callback은 주어진 학습 단계에서 적용될 수 있는 함수들의 집합입니다. 여러분은 모델의 훈련 도중 모델 내의 상태와 통계를 보기 위해 callbacks를 이용할 수 있습니다. callbacks의 리스트(키워드 인수 `callbacks`로)를 `Sequential` 또는 `Model` 클래스의 `.fit()` 메소드에 전달할 수 있습니다. 주어진 callbacks의 메소드는 훈련의 각 단계별로 호출될 것입니다. --- @@ -53,8 +53,8 @@ __Arguments__ - __stateful_metrics__: 에포크 단위별로 평균을 취하지 *말아야* 할 반복될 수 있는 측정 단위의 이름(스트링) - 이 리스트에 해당하는 측정 단위들은 'on_epoch_end' log에 값 그대로 - 포함 되며, 다른 측정 단위들은 'on_epoch_end'에 평균되어 들어갑니다. + 이 리스트에 해당하는 측정 단위들은 `on_epoch_end` log에 값 그대로 + 포함 되며, 다른 측정 단위들은 `on_epoch_end`에 평균되어 들어갑니다. ---- @@ -66,7 +66,6 @@ keras.callbacks.TerminateOnNaN() ``` 훈련 도중 loss 값이 NaN이 나왔을 때 종결시키는 콜백. -Callback that terminates training when a NaN loss is encountered. ---- @@ -101,10 +100,10 @@ __Raises__ keras.callbacks.History() ``` -'History' 오브젝트에 이벤트를 기록하는 콜백. +`History` 오브젝트에 이벤트를 기록하는 콜백. 이 콜백은 모든 케라스 모델에 자동적으로 적용됩니다. -'History' 오브젝트는 모델의 'fit' 메소드에 의해 +`History` 오브젝트는 모델의 `fit` 메소드에 의해 반환됩니다. ---- @@ -116,36 +115,34 @@ keras.callbacks.History() keras.callbacks.ModelCheckpoint(filepath, monitor='val_loss', verbose=0, save_best_only=False, save_weights_only=False, mode='auto', period=1) ``` -Save the model after every epoch. +모든 에포크 이후에 모델을 저장합니다. -`filepath` can contain named formatting options, -which will be filled with the values of `epoch` and -keys in `logs` (passed in `on_epoch_end`). +`filepath`는 포매팅 옵션으로 경로를 지정할 수 있으며, +`epoch`의 값들과 `logs`(`on_epoch_end`로부터 전달된) +값들을 갖고 있게 됩니다. + +예를 들어: 만약 `filepath` 가 `weights.{epoch:02d}-{val_loss:.2f}.hdf5`라면, +모델 체크포인트는 파일명에 에포크의 수와 validation loss를 포함하게 됩니다. -For example: if `filepath` is `weights.{epoch:02d}-{val_loss:.2f}.hdf5`, -then the model checkpoints will be saved with the epoch number and -the validation loss in the filename. __Arguments__ -- __filepath__: string, path to save the model file. -- __monitor__: quantity to monitor. -- __verbose__: verbosity mode, 0 or 1. -- __save_best_only__: if `save_best_only=True`, - the latest best model according to - the quantity monitored will not be overwritten. -- __mode__: one of {auto, min, max}. - If `save_best_only=True`, the decision - to overwrite the current save file is made - based on either the maximization or the - minimization of the monitored quantity. For `val_acc`, - this should be `max`, for `val_loss` this should - be `min`, etc. In `auto` mode, the direction is - automatically inferred from the name of the monitored quantity. -- __save_weights_only__: if True, then only the model's weights will be - saved (`model.save_weights(filepath)`), else the full model - is saved (`model.save(filepath)`). -- __period__: Interval (number of epochs) between checkpoints. +- __filepath__: 스트링, 모델을 저장하는 경로 +- __monitor__: 모니터하는 값 +- __verbose__: 자세함의 정도를 설정하는 모드, 0 또는 1. +- __save_best_only__: `save_best_only=True` 라면, + 측정된 값 기준 가장 좋은 모델 중 마지막 모델이 더 + 새로운 모델에 의해 대체되지 않습니다. +- __mode__: {auto, min, max}중 하나 + `save_best_only=True`라면, 현재 저장된 파일을 겹쳐 쓸지에 + 대한 결정이 모니터되는 값의 최대화, 또는 최소화에 의해 결정 + 됩니다. `val_acc`의 경우 `max`가 되어야 하고, `val_loss`의 + 경우 `min`이 되어야 하는 식입니다. `auto` 모드에서는 측정되는 + 값의 이름에 따라 자동으로 이 방향이 결정됩니다. +- __save_weights_only__: True 라면, 모델의 가중치만 + (`model.save_weights(filepath)`)로 저장되고, False 라면 전체 + 모드가 (`model.save(filepath)`)로 저장이 됩니다. +- __period__: 체크포인트 간극(에포크의 수). ---- @@ -156,32 +153,27 @@ __Arguments__ keras.callbacks.EarlyStopping(monitor='val_loss', min_delta=0, patience=0, verbose=0, mode='auto', baseline=None, restore_best_weights=False) ``` -Stop training when a monitored quantity has stopped improving. +측정되는 수치가 더 이상 개선되지 않을 때 훈련을 멈춥니다. __Arguments__ -- __monitor__: quantity to be monitored. -- __min_delta__: minimum change in the monitored quantity - to qualify as an improvement, i.e. an absolute - change of less than min_delta, will count as no - improvement. -- __patience__: number of epochs with no improvement - after which training will be stopped. -- __verbose__: verbosity mode. -- __mode__: one of {auto, min, max}. In `min` mode, - training will stop when the quantity - monitored has stopped decreasing; in `max` - mode it will stop when the quantity - monitored has stopped increasing; in `auto` - mode, the direction is automatically inferred - from the name of the monitored quantity. -- __baseline__: Baseline value for the monitored quantity to reach. - Training will stop if the model doesn't show improvement - over the baseline. -- __restore_best_weights__: whether to restore model weights from - the epoch with the best value of the monitored quantity. - If False, the model weights obtained at the last step of - training are used. +- __monitor__: 모니터되는 측정값 +- __min_delta__: 모니터되는 측정값이 개선이라고 판단될 수 있는 + 최소한의 변화, i.e. min_delta의 절댓값보다 작은 값이 바뀔 + 경우, 개선이라고 판단되지 않습니다. +- __patience__: 값이 더 이상 개선이 되지 않을 때 훈련이 중단 + 되기 전까지의 에포크 수 +- __verbose__: 자세함의 정도를 설정하는 모드. +- __mode__: {auto, min, max}중 하나. `min` 모드에서는, + 수치가 더 이상 감소하지 않을 때 훈련이 멈춥니다; + `max` 모드에서는, 수치가 더 이상 증가하지 않을 때 + 훈련이 멈춥니다; `auto` 모드에서는, 측정되는 수치의 + 이름에 따라 해당하는 방향이 자동으로 결정됩니다. +- __baseline__: 모니터되는 값이 가져야 할 기준치. + 이 기준치 이상 모델이 더 좋아지지 않을 때 훈련은 멈춥니다. +- __restore_best_weights__: 측정된 수치가 가장 좋았을 때의 모델 + 가중치를 다시 불러올 지를 정해줍니다. False 라면, 훈련의 + 마지막 단계에서 얻은 가중치를 사용합니다. ---- @@ -192,7 +184,7 @@ __Arguments__ keras.callbacks.RemoteMonitor(root='http://localhost:9000', path='/publish/epoch/end/', field='data', headers=None, send_as_json=False) ``` -Callback used to stream events to a server. +서버로 스트리밍 할 때 이용되는 콜백. Requires the `requests` library. Events are sent to `root + '/publish/epoch/end/'` by default. Calls are From e15285bf9d7aa1b95ef99feea3126632f487aa60 Mon Sep 17 00:00:00 2001 From: Hyung Jin Harry Chung Date: Fri, 15 Feb 2019 16:15:01 +0900 Subject: [PATCH 3/4] Update callbacks.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tensorboard까지 update --- sources/callbacks.md | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/sources/callbacks.md b/sources/callbacks.md index a3172a87..2ef0df95 100644 --- a/sources/callbacks.md +++ b/sources/callbacks.md @@ -186,23 +186,20 @@ keras.callbacks.RemoteMonitor(root='http://localhost:9000', path='/publish/epoch 서버로 스트리밍 할 때 이용되는 콜백. -Requires the `requests` library. -Events are sent to `root + '/publish/epoch/end/'` by default. Calls are -HTTP POST, with a `data` argument which is a -JSON-encoded dictionary of event data. -If send_as_json is set to True, the content type of the request will be -application/json. Otherwise the serialized JSON will be send within a form +`requests` 라이브러리를 필요로 합니다. +사건들은 디폴트로 `root + '/publish/epoch/end/'` 로 보내집니다. 콜은 HTTP 포스트 +로 지정되고, `data` 전달인자에 JSON으로 인코딩된 데이터가 들어갑니다. send_as_json이 +True로 설정되면 내용물의 형식이 application/json이 될 것이고, 그렇지 않다면 JSON이 +직렬화되어 전송됩니다. __Arguments__ -- __root__: String; root url of the target server. -- __path__: String; path relative to `root` to which the events will be sent. -- __field__: String; JSON field under which the data will be stored. - The field is used only if the payload is sent within a form - (i.e. send_as_json is set to False). -- __headers__: Dictionary; optional custom HTTP headers. -- __send_as_json__: Boolean; whether the request should be send as - application/json. +- __root__: 스트링; 타겟 서버의 루트 url +- __path__: 스트링; `root` 에 상대적인 경로로, 이벤트가 보내지는 경로 +- __field__: 스트링; 데이터가 저장되는 JSON의 field. + 정보가 형식에 맞춰 보내질 때(send_as_json이 False일 때)만 field가 이용됩니다. +- __headers__: 딕셔너리; 선택적인 커스텀 HTTP 헤더. +- __send_as_json__: 불린 자료형; 데이터가 application/json으로 보내질지의 여부. ---- @@ -213,14 +210,13 @@ __Arguments__ keras.callbacks.LearningRateScheduler(schedule, verbose=0) ``` -Learning rate scheduler. +학습 속도 스케쥴러. __Arguments__ -- __schedule__: a function that takes an epoch index as input - (integer, indexed from 0) and current learning rate - and returns a new learning rate as output (float). -- __verbose__: int. 0: quiet, 1: update messages. +- __schedule__: 입력으로 에포크 인덱스(정수, 인덱스는 0에서 시작) + 와 학습 속도를 받고 새로운 학습 속도를 출력합니다(부동소수점). +- __verbose__: 정수. 0: 메세지를 출력하지 않습니다, 1: 메세지를 업데이트 합니다. ---- @@ -231,11 +227,13 @@ __Arguments__ keras.callbacks.TensorBoard(log_dir='./logs', histogram_freq=0, batch_size=32, write_graph=True, write_grads=False, write_images=False, embeddings_freq=0, embeddings_layer_names=None, embeddings_metadata=None, embeddings_data=None, update_freq='epoch') ``` -TensorBoard basic visualizations. +텐서보드의 기본적인 시각화. -[TensorBoard](https://www.tensorflow.org/guide/summaries_and_tensorboard) -is a visualization tool provided with TensorFlow. +[텐서보드](https://www.tensorflow.org/guide/summaries_and_tensorboard) +는 텐서플로우와 함께 제공되는 시각화 도구입니다. +이 콜백은 텐서보드를 위한 로그를 작성하며, 여러분의 훈련과 테스트 척도에 대한 +동적 This callback writes a log for TensorBoard, which allows you to visualize dynamic graphs of your training and test metrics, as well as activation histograms for the different From 4a483ce01024720239a78040024a52110b75049b Mon Sep 17 00:00:00 2001 From: Hyung Jin Harry Chung Date: Fri, 15 Feb 2019 16:33:06 +0900 Subject: [PATCH 4/4] =?UTF-8?q?Tensorboard=20=EC=A4=91=EA=B0=84=EA=B9=8C?= =?UTF-8?q?=EC=A7=80=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/callbacks.md | 48 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/sources/callbacks.md b/sources/callbacks.md index 2ef0df95..03fadeee 100644 --- a/sources/callbacks.md +++ b/sources/callbacks.md @@ -232,40 +232,34 @@ keras.callbacks.TensorBoard(log_dir='./logs', histogram_freq=0, batch_size=32, w [텐서보드](https://www.tensorflow.org/guide/summaries_and_tensorboard) 는 텐서플로우와 함께 제공되는 시각화 도구입니다. -이 콜백은 텐서보드를 위한 로그를 작성하며, 여러분의 훈련과 테스트 척도에 대한 -동적 -This callback writes a log for TensorBoard, which allows -you to visualize dynamic graphs of your training and test -metrics, as well as activation histograms for the different -layers in your model. - -If you have installed TensorFlow with pip, you should be able -to launch TensorBoard from the command line: +이 콜백은 텐서보드를 위한 로그를 작성하며, 여러분의 훈련과 테스트 척도에 대한 동적 그래프, +활성화 함수에 대한 히스토그램, 그리고 여러분의 모델에 대한 서로 다른 레이어를 시각화할 +수 있게 합니다. + +만약 여러분이 텐서플로우를 pip을 이용해 설치했다면, 다음 커맨드로 텐서보드를 론칭할 수 있습니다. +커맨드 라인으로 텐서보드 론칭하기: ```sh tensorboard --logdir=/full_path_to_your_logs ``` -When using a backend other than TensorFlow, TensorBoard will still work -(if you have TensorFlow installed), but the only feature available will -be the display of the losses and metrics plots. +텐서플로우가 아닌 다른 백엔드를 이용하고 있더라도 텐서보드는 동작합니다(텐서플로우가 +설치되어있다는 전제 하에). 그러나 시각화가 가능한 특성들은 손실 함수와 측정 척도에 대한 +플롯 뿐입니다. __Arguments__ -- __log_dir__: the path of the directory where to save the log - files to be parsed by TensorBoard. -- __histogram_freq__: frequency (in epochs) at which to compute activation - and weight histograms for the layers of the model. If set to 0, - histograms won't be computed. Validation data (or split) must be - specified for histogram visualizations. -- __write_graph__: whether to visualize the graph in TensorBoard. - The log file can become quite large when - write_graph is set to True. -- __write_grads__: whether to visualize gradient histograms in TensorBoard. - `histogram_freq` must be greater than 0. -- __batch_size__: size of batch of inputs to feed to the network - for histograms computation. -- __write_images__: whether to write model weights to visualize as - image in TensorBoard. +- __log_dir__: 로그 파일이 저장되는 디렉토리로, 텐서보드를 통해 분석되는 + 파일이 저장됩니다. +- __histogram_freq__: 모델의 레이어에 대한 활성화 정도와 가중치 정도를 + 계산하는 빈도(에포크 단위). 만약 0으로 설정 되면, 히스토그램은 계산되지 않을 것입니다. + 검증 데이터(혹은 split)는 히스토그램 시각화를 위해 특정되어야 합니다. +- __write_graph__: 텐서보드를 이용해 그래프를 시각화할지에 대한 여부. + write_graph가 True로 설정될 경우 로그 파일의 크기가 꽤 커질 수 있습니다. +- __write_grads__: 텐서보드를 이용해 경사도를 시각화할지에 대한 여부. + `histogram_freq`는 0보다 커야 합니다. +- __batch_size__: 히스토그램을 계산하기 위해 + 네트워크에 입력으로 집어 넣는 입력 배치의 크기. +- __write_images__: 모델 가중치를 텐서보드에서 이미지로 저장할지에 대한 여부. - __embeddings_freq__: frequency (in epochs) at which selected embedding layers will be saved. If set to 0, embeddings won't be computed. Data to be visualized in TensorBoard's Embedding tab must be passed