chainer.functions.square¶
-
chainer.functions.
square
(x)[source]¶ Elementwise square function.
\[y_i = x_i ^ 2.\]- Parameters
x (
Variable
or N-dimensional array) – Input variable. A \((s_1, s_2, ..., s_N)\) -shaped float array.- Returns
Output variable. A \((s_1, s_2, ..., s_N)\) -shaped float array.
- Return type
Example
>>> x = np.arange(6).reshape(2,3).astype(np.float32) >>> x array([[0., 1., 2.], [3., 4., 5.]], dtype=float32) >>> y = F.square(x) >>> y.shape (2, 3) >>> y.array array([[ 0., 1., 4.], [ 9., 16., 25.]], dtype=float32)