Re-update optimizer.learn_weights to use scipy.optimizer.fmin_l_bfgs_b; ensure that the gradient is a numpy array.