레이어의 반복이 끝난 후 비용 함수의 계산
비용 함수의 종류에 따라 이를 시행,
# 모든 레이어를 돌고 난 후
loss = self.compile_dir.get('loss')
# 비용 함수
if(loss == 'mse'):
cost_result = self.cost.errer_squared_sum(data, target)
비용 함수 클래스
import numpy as np
# 비용 함수 클래스, 비용 함수의 종류에 따라 다른 클래스 내 함수를 사용한다.
class cost_function:
# 오차 제곱합
def errer_squared_sum(self, predict, target):
return np.sum(0.5*((predict - target)**2))
# 오차 제곱합 미분 함수
def diff_error_squared_sum(self, predict, target):
return predict - target
'ml_framework' 카테고리의 다른 글
fit(delta_weight_update) (0) | 2023.04.25 |
---|---|
fit(delta) (0) | 2023.04.24 |
fit(dense) (0) | 2023.04.23 |
Sequential(3) (0) | 2023.04.22 |
Sequential(2) (0) | 2023.04.22 |