寻找平方成本函数 theano

finding square cost function theano

我是 theano 和神经网络的新手。我正在尝试计算平方成本函数 summation_over_components_of_y((y-x)**2),其中 x 是一个常数,y 是一个向量。

components,updates = theano.scan(fn=lambda coeff, power, free_var:
                                   coeff * (free_var ** power),
                                outputs_info=None,
                                sequences=[input_vector, full_range],
                                non_sequences=x)

我使用扫描函数来获取组件。如何获取需要的值sum((component-constant)**2)?

theano.tensor.sum((y-x)*(y-x))

旁注,如果 x 是标量常数,它将被广播。