Fix optimizer loading

This commit is contained in:
Explosion Bot 2017-10-28 11:58:16 +02:00
parent b22e42af7f
commit fb0c96f39a
1 changed files with 2 additions and 3 deletions

View File

@ -379,8 +379,7 @@ class Language(object):
return return
if sgd is None: if sgd is None:
if self._optimizer is None: if self._optimizer is None:
self._optimizer = Optimizer(Model.ops, 0.001, self._optimizer = Adam(Model.ops, 0.001)
beta1=0.9, beta2=0.0, nesterov=True)
sgd = self._optimizer sgd = self._optimizer
grads = {} grads = {}
def get_grads(W, dW, key=None): def get_grads(W, dW, key=None):
@ -422,7 +421,7 @@ class Language(object):
L2 = util.env_opt('L2_penalty', 1e-6) L2 = util.env_opt('L2_penalty', 1e-6)
max_grad_norm = util.env_opt('grad_norm_clip', 1.) max_grad_norm = util.env_opt('grad_norm_clip', 1.)
self._optimizer = Optimizer(Model.ops, learn_rate, L2=L2, beta1=beta1, self._optimizer = Optimizer(Model.ops, learn_rate, L2=L2, beta1=beta1,
beta2=beta2, eps=eps, nesterov=True) beta2=beta2, eps=eps)
self._optimizer.max_grad_norm = max_grad_norm self._optimizer.max_grad_norm = max_grad_norm
self._optimizer.device = device self._optimizer.device = device
return self._optimizer return self._optimizer