Closed
Description
Tensorflow supports multiple reduction axes. Numpy does not. Is this a useful feature to have?
In [30]: import tensorflow as tf
In [31]: sess = tf.Session()
I tensorflow/core/common_runtime/gpu/gpu_device.cc:839] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
In [32]: a = np.arange(24).reshape((2, 3, 4))
In [33]: ta = tf.constant(a)
In [34]: sess.run(tf.reduce_max(a, reduction_indices=0))
Out[34]:
array([[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]])
In [35]: sess.run(tf.reduce_max(a, reduction_indices=[0, 2]))
Out[35]: array([15, 19, 23])
In [36]: np.maximum.reduce(a, axis=0)
Out[36]:
array([[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]])
In [37]: np.maximum.reduce(a, axis=[0, 2])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-37-b4f45c212008> in <module>()
----> 1 np.maximum.reduce(a, axis=[0, 2])
TypeError: an integer is required
Metadata
Metadata
Assignees
Labels
No labels