Numpy Array Broadcasting In Python Explained

preview_player
Показать описание
How Numpy adds arrays of different shapes.

SUPPORT ME ⭐
---------------------------------------------------

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Thanks for making it intuitive! Maybe I won't have to mess around in a python console to figure stuff out every time this comes up now!

amaarquadri
Автор

Thanks for explanation. I have been learning ML and neural networks on Coursera and they did not explain broadcasting as well as you did.
The example of iteratively doing the adds on "incompatible" matrices and comparing to the answer given by numpy really helped a lot in my undersanding of broadcasting.

LouisDuran
Автор

Thank you for making it interesting and easy to learn.

siddhantkandi
Автор

Excellent video, you explain it perfectly, thanks a lot ;)

mariabarbarasalinasluna
Автор

Huh i've been coding my own Math library in C# and i've tackled Matrix(array) operations, i defined the regular Matrix addition that requires same Matrix dimensions, but i could i add this too, thanks!

ZeroSleap
Автор

@mCoding Have you done any work in the area of Machine Learning and Deep Neural Networks?

LouisDuran
Автор

11:36 Disclaimer: Actually, you should avoid using reshape in most cases. Instead, try to always use

1) indexing with np.newaxis/None to add new "1" dimensions
2) x.squeeze(axis=N) to remove a "1" dimension in Nth position
3) x.transpose(...) or x.swapaxes(...) to change the order of axes
4) x.flat/flatten when you want to "stretch" your N-dim array into a flat 1D vector.

You should only really use reshape when you really actually want to change the shape, while also rearranging the order of the elements.
The reason for this recommendation is that it's very easy to make a mistake with reshape and still end up with "valid" code.
For example, np.ones(2, 3).reshape(3, 2) might look like it transposes the dimensions, but actually it "reinterprets" the shape of the array.
Additionally, reshape **sometimes** produces views of the original arrays and **sometimes** produces copies.

ruroruro
Автор

excellent video. btw, could you tell what the text font being used in this video?

htvyghh
Автор

At 7:19 isn't y shape == (1, 3) ? And not (3, 1) ?

JoaoVitorBRgomes
Автор

My answer for the exercise at the end...




The array [[[[2]], [[3]], [[4]]]] which has shape (1, 3, 1, 1)

rolininthemud
Автор

For example 3, the shape of y should be (1, 1, 1, 1, 17) rather than (1, 7, 1, 1, 17)

ziweihuang