refactored
This commit is contained in:
+3
-3
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user