'Sets the weights of the model.
# Arguments
weights: Should be a list
of Numpy arrays with shapes and types matching
the output of `model.get_weights()`.'

def set_weights(self, weights):

    if legacy_models.needs_legacy_support(self):
        layers = legacy_models.legacy_sequential_layers(self)
        for layer in layers:
            nb_param = len(layer.weights)
            layer.set_weights(weights[:nb_param])
            weights = weights[nb_param:]
    if (not self.built):
        self.build()
    self.model.set_weights(weights)
