chainer.functions.sum_to¶
-
chainer.functions.
sum_to
(x, shape)[source]¶ Sum elements along axes to output an array of a given shape.
- Parameters
x (
Variable
or N-dimensional array) – Input variable.shape (tuple of int) – The target shape.
- Returns
Output variable of shape
shape
.- Return type
Example
>>> x = np.array([[1., 2., 3.], [4., 5., 6.]]) >>> x array([[1., 2., 3.], [4., 5., 6.]]) >>> y = F.sum_to(x, (1, 3)) >>> y variable([[5., 7., 9.]]) >>> z = F.sum_to(x, (2, 1)) >>> z variable([[ 6.], [15.]])