3、tensorflow变量运算,数学运算

import tensorflow as tf
import numpy as np

a = tf.range(1,7)
a = tf.reshape(a,[2,3])
b = tf.constant([[2],[2],[2]])
#b = tf.reshape(b,[1,-1])
c = tf.matmul(a,b)
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(a))
    print(sess.run(b))
    print(sess.run(c))
[[1 2 3]
 [4 5 6]]
[[2]
 [2]
 [2]]
[[12]
 [30]]

参考:https://blog.csdn.net/mzpmzk/article/details/78636142
1. 加减乘除
2. (x = tf.reshape(x,[-1,1]))
3. tf.matmul(a,b)
4. tf.transpose
5. tf.segment_sum
#m = tf.constant([5,1,7,2,3,4,1,3])
#s_id = [0,0,0,1,2,2,3,3]
#s.run(tf.segment_sum(m, segment_ids=s_id))

6. tf.unique
tf.equal
tf.where

7. tf.argmax
tf.nn.softmax()
tf.nn.top_k #https://blog.csdn.net/mzpmzk/article/details/78636217

原文地址:https://www.cnblogs.com/qiezi-online/p/13913343.html