def set_params(self, **params): # mapping: ops.name -> ops ops = {i.name: i for i in self._seq_ops.ops} for name, p in params.iteritems(): if name in ops: for param_old, param_new in zip(ops[name].parameters, p): if not isinstance(param_new, np.ndarray): param_new = K.get_value(param_new) K.set_value(param_old, param_new) return self
def event(self, event_name): if event_name == TrainSignal.ROLLBACK: from odin import backend as K self.lr_value *= self.decay_rate K.set_value(self.lr, self.lr_value)
def set_parameters(self, W=None, b=None): if W is not None: K.set_value(self._model.get('W'), W) if self.fit_intercept and b is not None: K.set_value(self._model.get('b'), b) return self