모델의 컴파일 단계에서 다음과 같은 코드를 사용했었다.

model.compile(loss='categorical_crossentropy' , optimizer='adam' , metrics=['accuracy'])

 

이에 대해 이 코드가 무엇인지 의문이 들었지만 그냥 뭐 쓰는거겠지 하고 넘어가는 경우도 있을 것이다.

위에서 사용한 코드들에 대해 keras API reference와 여러 자료들을 바탕으로 직접 정리해보았다,

 

keras API reference (https://keras.io/api/)

 

Keras documentation: Keras API reference

 

keras.io

 

 

Loss Function

Losses reference (https://keras.io/api/losses/)

 

Keras documentation: Losses

Losses The purpose of loss functions is to compute the quantity that a model should seek to minimize during training. Available losses Note that all losses are available both via a class handle and via a function handle. The class handles enable you to pas

keras.io

 

Optimizer

Optimizers reference (https://keras.io/api/optimizers/)

 

Keras documentation: Optimizers

Optimizers Usage with compile() & fit() An optimizer is one of the two arguments required for compiling a Keras model: from tensorflow import keras from tensorflow.keras import layers model = keras.Sequential() model.add(layers.Dense(64, kernel_initializer

keras.io

 

서로 다른 유형의 문제와 목표에 따라 서로 다른 평가 지표가 적합합니다.  각각을 사용하는 경우에 대한 몇 가지 지침은 다음과 같다.

Accuracy:  클래스가 균형이 잡혀 있고 올바른 예측의 비율이 높을 때.

Precision: 오차가 큰 것(FP)이 오차가 작은 것(FN)보다 더 치명적인 경우에는 precision을 최소화하려면 사용합니다.

Recall(Sensitivity): 오차가 작은 것(FN)이 오차가 큰 것(FP)보다 더 치명적인 경우에는 recall을 최소화하려면 사용합니다.

F1-Score: precision과 recall 사이의 균형이 중요하고 오차가 큰 것과 오차가 작은 것 사이의 좋은 균형을 찾으려면 사용합니다.

ROC-AUC: 클래스 분포가 균형이 잡히지 않은 경우 또는 이진 분류기의 전체 성능을 평가하려면 사용합니다.


MAE: 목표가 회귀 문제에서 오류의 평균 크기를 측정하는 것일 때.

MSE: 목표가 오류의 평균 크기를 측정하고 회귀 문제에서 큰 오류에 더 많은 페널티를 주는 것입니다.

 

 

Metric

Metrics reference (https://keras.io/api/metrics/)

 

Keras documentation: Metrics

Metrics A metric is a function that is used to judge the performance of your model. Metric functions are similar to loss functions, except that the results from evaluating a metric are not used when training the model. Note that you may use any loss functi

keras.io

 

+ Recent posts