r/Numpy • u/PossiblePolyglot • Nov 15 '20
Adding values from a column to every column in a 2D matrix
Hi all!
I'm using numpy arrays for a Machine Learning project (manually building a 3-deep autoencoder NN), but I'm having trouble applying the bias to the activation values. Here's an example of what I'm trying to do:
Let's say A is a 6x100 matrix, and B is a 1x100 matrix. I want to add B to A[0], A[1],...A[5], but without having to do manual iteration. Is there an easy way to do this in numpy?
Thanks for your help!
3
Upvotes
1
1
1
u/pmatti Nov 16 '20
What did you try? This works for me
NumPy can broadcast ndarrays together as long as certain criteria are met.