chainer.functions.sum_to

chainer.functions.sum_to(x, shape)[source]

Sum elements along axes to output an array of a given shape.

Parameters
Returns

Output variable of shape shape.

Return type

Variable

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.]])