Reputation: 3673
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])
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
Upvotes: 2
Views: 4315
Reputation: 3673
The needed function is called tf.reduce_prod
and can be found here: https://www.tensorflow.org/api_docs/python/tf/reduce_prod
Upvotes: 4
Reputation: 20214
use reduce
import functools
m_final = functools.reduce(lambda x, y: tf.multiply(x, y), your_matrix_list)
Upvotes: -1