TensorFlow学习笔记(1)tf.reduce_mean,求平均值

    import tensorflow as tf
    import numpy as np

    #  Computes the mean of elements across dimensions of a tensor. (deprecated arguments)
    
    #  tf.reduce_mean(
    #      input_tensor,
    #      axis=None,
    #      keepdims=None,
    #      name=None,
    #      reduction_indices=None,
    #      keep_dims=None
    #      )
    
    c = np.array([[3.,4], [5.,6], [6.,7]])
    
    step = tf.reduce_mean(c, 1)
    with tf.Session() as sess:
        print(sess.run(step))

输出

[3.5 5.5 6.5]

也就是
[3.,4]的平均值是3.5,类推

用例对应的源代码,觉得有帮助可以Star

    原文作者:谢昆明
    原文地址: https://www.jianshu.com/p/b8271c9d5ce3
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞