인공지능/이론 정리

[Deep learning book] 5.3 Hyperparameters and Validation Sets

고등어찌짐 2022. 9. 6. 20:27

5.3 Hyperparameters and Validation Sets

  • Hyperparmeter examples
    - degree of the polynomial : capacity hyperparameter
    - λ value used to control the strength of weight decay

    - (Left) very large λ : force the model to learn a function with no slope, underfits because it can only represent a constant function
    - (Center) medium value of λ : recovers a curve with the right general shape
    - (Right) With weight decay approaching zero

  • train set
    used to learn the parameters

  • validation set
    - always construct the validation set from the training data
    - no example from the test set can be used in the validation set
    - estimate the generalization error during or after training, allowing for the hyperparameters to be updated accordingly
    - used to “train” the hyperparameters

  • test set
    - composed of examples coming from the same distribution as the training set
    - estimate the generalization error
    - not used in any way to make choices about the model, including its hyperparameters

5.3.1 Cross-Validation

  • Cross-Validation
    - fixed training set and a fixed test set can be problematic
    - When the dataset is too small
    - repeating the training and testing computation on different randomly chosen subsets or splits of the original dataset
    - increased computational cost

  • k-fold cross-validation procedure
    - taking the average test error across k trials
    - i-th subset of the data is used as the test set, and the rest of the data is used as the training set
    - one problem is that no unbiased estimators of the variance of such average error estimators exist, but approximations are typically used

 


5.3 Hyperparameters and Validation Sets

  • Hyperparmeter examples
    - 다항식의 차수 : capacity hyperparameter
    - weight decay 값을 제어하기 위해 사용되는 λ 

    - (Left) very large λ : λ 가 매우커져 상수함수가 되기때문에 underffing 됨
    - (Center) medium value of λ : 일반적인 알맞은 모양으로 학습
    - (Right) weight decay 값이 0 에 가까워짐 : overfitting 됨 ( 모델의 weight 값들을 컨트롤 할 수 없음 ) 

  • train set
    파라미터를 학습하기 위해 사용 
    used to learn the parameters

  • validation set
    - 항상 train set 에서부터 만드는 데이터 셋
    - test set 과 겹치는 example 이 있으면 안됨 
    - 학습 중, 혹은 학습 후에 generalization error 를 관찰하면서 모델의 하이퍼파라미터가 올바르게 학습되도록 함


    - always construct the validation set from the training data
    - no example from the test set can be used in the validation set
    - estimate the generalization error during or after training, allowing for the hyperparameters to be updated accordingly
    - used to “train” the hyperparameters,

  • test set
    - training set 과 같은 분포로 구성된 examples set 
    - generalization error 를 측정하는데 사용
    - 하이퍼파라미터 업데이트 혹은 모델에 대한 선택 사항을 결정하는 데 사용하지 않음 

5.3.1 Cross-Validation

  • Cross-Validation
    - 고정된 training / test set 로 문제 소지가 있는 경우 사용 
    - 데이터셋이 너무 작은 경우 활용 가능
    - 원래의 dataset 를 랜덤하게  train set 과 test set 를 나누고 골라서 train, test 과정을 반복하는 것 
    - 다만 계산 비용이 증가함 
  • k-fold cross-validation procedure
    - k 번을 반복하면서 test error 의 평균을 측정
    - i 번째 시도에서, k 개 중 i 번째의 subset 을 test set 으로 사용하고, 나머지는 tarin set 으로 사용함
    - 평균 test error 의 분산에 대한 unbiased estimators ( 불편 추정량 ) 이  없다는 문제가 있지만, 근사치를 일반적으로 사용 
    - K 가 높을수록 평가의 bias ( 편중된 정도 ) 는 낮아지지만, 결과의 분산이 높아질 수 있음 
    - 편향이 높음 = 예측값과 정답이 멀리 떨어져 있음
    - 분산이 높음 = 예측값들이 서로 멀리 떨어져 있음