Tfjs: Tensor/Matrix and math operations + reduction

Created on 25 Oct 2018  路  6Comments  路  Source: tensorflow/tfjs

To get help from the community, check out our Google group.

TensorFlow.js version

0.13.2

Describe the problem or feature request

I'd like to request a feature reduce that cumulatively applies the math function onto each item in the Tensor and produce a new tensor with a new shape.

Such API might be invoked like

tf.tensor2d([[1, 2], [3, 4]]).add.reduce(0)
// column wise reduction
// Result: [4, 6]<tensor>

tf.tensor2d([[1, 2], [3, 4]]).add.reduce(1)
// Row wise reduction
// Result: [3, 7]<tensor>

This feature request is heavily influenced by https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.ufunc.reduce.html

core awaiting response feature

Most helpful comment

Ah, yes it does look like prod reduction op was recently added. Seems like this issue can be closed now!

/cc @dsmilkov

All 6 comments

This is alway i think, I totally agree with Jason

TF.js API is closely aligned with the TF Python API. Does such a reduce feature exist in TF Python?

I couldn't find a TF Python API that is close to reduce ;(

@JasonShin This should work:

const x = tf.tensor2d([[1, 2], [3, 4]]);

x.sum(axis=1).print(); // [3, 7]

You can read more about reduce operations here

@manrajgrover We were actually looking for both prod and sum methods but they weren't showing up on https://js.tensorflow.org/api/0.13.0/, which is the default doc site that the Google search result takes you to!

Ah, yes it does look like prod reduction op was recently added. Seems like this issue can be closed now!

/cc @dsmilkov

Was this page helpful?
0 / 5 - 0 ratings