refactored

This commit is contained in:
2026-01-10 16:46:27 +01:00
parent 1722a68b2a
commit be64b0f8ce
+3 -3
View File
@@ -99,13 +99,13 @@ class Entity:
# compute L1 term and penalize cost function (d_whv) # compute L1 term and penalize cost function (d_whv)
l1_norm = np.sum(np.abs(self.state.w_hv)) l1_norm = np.sum(np.abs(self.state.w_hv))
l1_term = params.l1_lambda*l1_norm*self.state.w_hv l1_term = params.l1_lambda*l1_norm
# compute L2 term and penalize cost function (d_whv) # compute L2 term and penalize cost function (d_whv)
l2_norm = np.sum(np.square(self.state.w_hv)) l2_norm = np.sum(np.square(self.state.w_hv))
l2_term = params.l2_lambda*l2_norm*self.state.w_hv l2_term = params.l2_lambda*l2_norm
self.grad.w_hv = params.momentum * self.grad.w_hv + lr * (d_whv-(l1_term+l2_term)) - lr * params.weight_decay * self.state.w_hv self.grad.w_hv = params.momentum * self.grad.w_hv + lr * (d_whv - self.state.w_hv*(l1_term+l2_term)) - lr * params.weight_decay * self.state.w_hv
return self.grad return self.grad