Skip to content
Advertisement

Finding the minimum of the N numpy matrices?

I want to find the minimum of N numpy matrices elementwise (but with a twist, read till the end). To show, I create 3 numpy matrices as follows:

JavaScript

I except my output d to be:

JavaScript

I also need to retain the information from where does the each element in the d matrix is coming from. So if I label a, b, c as class 0, 1, 2. In the end I need to have a m matrix like this:

JavaScript

I prefere no-loops based numpy approach.

Advertisement

Answer

To find the minimum numbers:

JavaScript

And their origins:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement