在Tensorflow中将Tensor的所有元素相乘 [英] Multiply all elements of Tensor in Tensorflow

查看:1096
本文介绍了在Tensorflow中将Tensor的所有元素相乘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的张量带有3个元素,我想彼此相乘。

I have tensor with 3 elements which I want to multiply with each others.

我的代码当前如下所示:

My code currently looks like this:

m1 = tf.multiply(y[0],y[1])
m2 = tf.multiply(m1,y[2])

哪个恕我直言很不灵活,我当然可以循环并遍历元素,但是我想知道是否tf已经提供了这样的功能吗?我在文档中找不到任何内容

Which imho is very unflexible, of course I could put a loop and iterate over the elements, but I was wondering if there is such functionallity already provded in tf ? I could not find anything in the docs

推荐答案

所需的函数称为 tf.reduce_prod ,可以在以下位置找到: https://www.tensorflow.org/ api_docs / python / tf / reduce_prod

The needed function is called tf.reduce_prod and can be found here: https://www.tensorflow.org/api_docs/python/tf/reduce_prod

这篇关于在Tensorflow中将Tensor的所有元素相乘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆