mean

paddle.fluid.layers.mean(x, name=None)[source]

Mean Operator calculates the mean of all elements in X.

Parameters
  • x (Variable) – (Tensor) The input of mean op

  • name (basestring|None) – Name of the output.

Returns

(Tensor) The output of mean op

Return type

out(Variable)

Examples

import paddle.fluid as fluid
import numpy

# Graph Organizing
input = fluid.data(
    name='data', shape=[2, 3], dtype='float32')
output = fluid.layers.mean(input)

# Create an executor using CPU as an example
place = fluid.CPUPlace()
exe = fluid.Executor(place)

# Execute
x_ndarray = numpy.ones([2, 3]).astype(numpy.float32)
res, = exe.run(fluid.default_main_program(),
               feed={'data':x_ndarray},
               fetch_list=[output])
print(res)
'''
Output Value:
[1.]
'''