NumPy broadcasting

We can grasp the general idea from the above example. Looking from the right to left: if we only have those 3 cases, then the broadcasting is valid:

  1. dimension is the same
  2. one of the dimension is 1
  3. one of the dimensions does not exist.

For the above example, look from right to left

first dimension: A and B are the same, good

second dimension: B is one, good

third dimension: A is one, good

fourth dimension: B doesn't exist, good.

So the broadcasting is valid.

For more details see here.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jimmy Shen

Jimmy Shen

Data Scientist/MLE/SWE @takemobi