'Sets the weights of the optimizer, from Numpy arrays.
Should only be called after computing the gradients
(otherwise the optimizer has no weights).
# Arguments
weights: a list of Numpy arrays. The number
of arrays and their shape must match
number of the dimensions of the weights
of the optimizer (i.e. it should match the
output of `get_weights`).
# Raises
ValueError: in case of incompatible weight shapes.'

def set_weights(self, weights):

    params = self.weights
    weight_value_tuples = []
    param_values = K.batch_get_value(params)
    for (pv, p, w) in zip(param_values, params, weights):
        if (pv.shape != w.shape):
            raise ValueError(((('Optimizer    weight    shape    ' + str(pv.shape)) + '    not    compatible    with    provided    weight    shape    ') + str(w.shape)))
        weight_value_tuples.append((p, w))
    K.batch_set_value(weight_value_tuples)
