Ejemplo n.º 1
0
 def on_epoch_begin(self, epoch, logs={}):
     assert hasattr(self.model.optimizer, 'lr'), \
         'Optimizer must have a "lr" attribute.'
     lr = self.schedule(epoch)
     assert type(
         lr
     ) == float, 'The output of the "schedule" function should be float.'
     K.set_value(self.model.optimizer.lr, lr)
Ejemplo n.º 2
0
Archivo: core.py Proyecto: lxastro/dlx
    def set_weights(self, weights):
        '''Set the weights of the unit.

        weights: a list of numpy arrays. The number of arrays and their shape must match
            number of the dimensions of the weights of the unit (i.e. it should match the
            output of `get_weights`).
        '''
        assert len(self.params) == len(weights), ('Provided weight array does not match unit weights (' +
                                                  str(len(self.params)) + ' unit params vs. ' +
                                                  str(len(weights)) + ' provided weights)')
        for p, w in zip(self.params, weights):
            if K.get_value(p).shape != w.shape:
                raise Exception('Weight shape %s not compatible with weight shape %s.' % (K.get_value(p).shape, w.shape))
            K.set_value(p, w)
Ejemplo n.º 3
0
    def set_weights(self, weights):
        '''Set the weights of the unit.

        weights: a list of numpy arrays. The number of arrays and their shape must match
            number of the dimensions of the weights of the unit (i.e. it should match the
            output of `get_weights`).
        '''
        assert len(self.params) == len(weights), (
            'Provided weight array does not match unit weights (' +
            str(len(self.params)) + ' unit params vs. ' + str(len(weights)) +
            ' provided weights)')
        for p, w in zip(self.params, weights):
            if K.get_value(p).shape != w.shape:
                raise Exception(
                    'Weight shape %s not compatible with weight shape %s.' %
                    (K.get_value(p).shape, w.shape))
            K.set_value(p, w)
Ejemplo n.º 4
0
 def on_epoch_begin(self, epoch, logs={}):
     assert hasattr(self.model.optimizer, 'lr'), \
         'Optimizer must have a "lr" attribute.'
     lr = self.schedule(epoch)
     assert type(lr) == float, 'The output of the "schedule" function should be float.'
     K.set_value(self.model.optimizer.lr, lr)
Ejemplo n.º 5
0
 def set_state(self, value_list):
     assert len(self.updates) == len(value_list)
     for u, v in zip(self.updates, value_list):
         K.set_value(u[0], v)
Ejemplo n.º 6
0
 def set_state(self, value_list):
     assert len(self.updates) == len(value_list)
     for u, v in zip(self.updates, value_list):
         K.set_value(u[0], v)