question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tensor/Matrix and math operations + reduction

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
manrajgrovercommented, Nov 2, 2018

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

/cc @dsmilkov

1reaction
manrajgrovercommented, Oct 30, 2018

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reduced Matrix Elements of Tensor Operators - AIP Publishing
Reduced matrix elements of a tensorial product of n tensor operators in the basis of N‐particle angular‐momentum eigenstates are expanded into a sum...
Read more >
MATRICES AND TENSORS - Springer Link
Matrices are reviewed briefly, and determinants, vectors, and tensors of order two are described. The application of this linear algebra to material that ......
Read more >
Matrix and Tensor Operations
This tutorial reviews the functions that Mathematica provides for building and working with matrices, vectors, and tensors. It focuses on functions that are ......
Read more >
Tensor Reduction — Topic 13 of Machine Learning Foundations
... we'll perform hands-on code demos in NumPy, TensorFlow, and PyTorch in order to learn about reduction, a common tensor operation in ML....
Read more >
Reduce the number of operations on a simple expression
I don't know whether there are good algorithms for computing ranks of higher tensors the way there are for matrices. Share.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found