chainer.functions.squared_difference

chainer.functions.squared_difference(x1, x2)[source]

Squared difference of input variables.

Parameters
Returns

(x1 - x2) ** 2 element-wise. A \((s_1, s_2, ..., s_N)\) -shaped float array.

Return type

Variable

Example

>>> x1 = np.arange(6).astype(np.float32)
>>> x1
array([0., 1., 2., 3., 4., 5.], dtype=float32)
>>> x2 = np.array([5, 4, 3, 2, 1, 0]).astype(np.float32)
>>> x2
array([5., 4., 3., 2., 1., 0.], dtype=float32)
>>> y = F.squared_difference(x1, x2)
>>> y.shape
(6,)
>>> y.array
array([25.,  9.,  1.,  1.,  9., 25.], dtype=float32)