美文网首页
Python 之 numpy 和 tensorflow 中的各种

Python 之 numpy 和 tensorflow 中的各种

作者: EO_eaf6 | 来源:发表于2020-07-27 18:15 被阅读0次

转自: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

相关文章

网友评论

      本文标题:Python 之 numpy 和 tensorflow 中的各种

      本文链接:https://www.haomeiwen.com/subject/eahtrktx.html