tf.accumulate_n()

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fyq201749/article/details/81913126

tf.accumulate_n() 对值求和
传参 :

tf.accumulate_n(
    inputs,#输入数据 数据需要封装成list 数据的秩要一致
    shape=None,#输出的矩阵模式
    tensor_dtype=None,#数据类型
    name=None
)

使用案例:

import tensorflow as tf

x = tf.constant(-1)
y = tf.constant([-1 + 2j, -2])
sess = tf.Session()
print(sess.run(tf.accumulate_n([x, x, x])))#-3
print(sess.run(tf.accumulate_n([y, y, y])))#[-3.+6.j,-6.+0.j]

猜你喜欢

转载自blog.csdn.net/fyq201749/article/details/81913126