Python 之 numpy 和 tensorflow 中的各种

2020-07-27  本文已影响0人  EO_eaf6

转自:https://www.cnblogs.com/liuq/p/9330134.html
tensorflow点乘 x=tv (2,3,4)(4,)(2,1)*(2,5)也可
对应元素相乘,有一个维度相等即可

t=tf.Variable([[[1,1,1,1],[2,2,2,2],[3,3,3,3]],[[4,4,4,4],[5,5,5,5],[6,6,6,6]]], dtype=tf.float32)
v=tf.Variable([10,10,10,10], dtype=tf.float32)
x=v*t
sess = tf.Session()
init = tf.global_variables_initializer()
sess.run(init)

print(sess.run(t))
print(sess.run(v))
print(sess.run(x))

结果:


image.png
上一篇 下一篇

猜你喜欢

热点阅读