Optimizer - set_weights : check weights length
@@ -106,6 +106,11 @@ class Optimizer(object):
ValueError: in case of incompatible weight shapes.
"""
params = self.weights
+ if len(params) != len(weights):
+ raise ValueError('Length of the specified weight list (' +
+ str(len(weights)) +
+ ') does not match the number of weights ' +
+ 'of the optimizer (' + str(len(params)) + ')')
weight_value_tuples = []
param_values = K.batch_get_value(params)
for pv, p, w in zip(param_values, params, weights):
