Error in

I could not debug this error that I am getting in neural_style.ipynb, please let me know where is I am doing wrong:

rn_mean = np.array([123.68, 116.779, 103.939], dtype=np.float32)
preproc = lambda x: (x - rn_mean)[:, :, :, ::-1]
deproc = lambda x,s: np.clip(x.reshape(s)[:, :, :, ::-1] + rn_mean, 0, 255)
img_arr = preproc(np.expand_dims(np.array(img),0))
shp = img_arr.shape
model = VGG16_Avg(include_top=False)

#grab conv layer from the end
layer = model.get_layer(‘block5_conv1’).output
#then target activation for this layer
layer_model = Model(model.input, layer)
target= K.variable(layer_model.predict(img_arr))

class Evaluator(object):
def init(self, f, shp):
self.f = f
self.shp = shp
def loss(self, x):
loss_, self.grad_values = self.f[x.reshape(self.shp)]
return loss_.astype(np.float64)
def grads(self, x):
return self.grad_values.flatten().astype(np.float64)

loss = metrics.mse(layer, target)
grads = K.gradients(loss, model.input)
evaluator = Evaluator(fn, shp)

def solve_image(eval_obj, niter, x):
for i in range(niter):
x, min_val, info = fmin_l_bfgs_b(eval_obj.loss, x.flatten(),
fprime=eval_obj.grads, maxfun=20)
x = np.clip(x, -127,127)
print(‘Current loss value:’, min_val)
imsave(dpath+‘res_at_iteration.png’, deproc(x.copy(), shp)[0])
return x

rand_img = lambda shape: np.random.uniform(-2.5, 2.5, shape)/100
x = rand_img(shp)

x = solve_image(evaluator, iterations, x)

TypeError: only integer scalar arrays can be converted to a scalar index

I changed:
loss = metrics.mse(layer, target)
loss = K.mean(metrics.mse(layer, targ))

to fix this error.