Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplying two matrices?? #24

Closed
mind-matrix opened this issue May 18, 2017 · 2 comments
Closed

Multiplying two matrices?? #24

mind-matrix opened this issue May 18, 2017 · 2 comments

Comments

@mind-matrix
Copy link

mind-matrix commented May 18, 2017

delta2 = np.dot(delta3, self.W2.T)*self.sigmoidPrime(self.z2)
This line appears in a function (forward) in the code. Whereby I noticed that z2 was a matrix (per your explanation). I am not that proficient in the python programming language so may not know what it means, but how does np.dot and * differ? The reason I ask this is because I discovered an anomaly in my code while trying to implement this by making a model with inputLayerSize=1, hiddenLayerSize=2 and outputLayerSize=1. Essentially, it should give me predictions for y for the equation y=2x (without knowing the equation firsthand, ofcourse). But when finding delta2 I am stuck because (W2) Transpose is of the order 1 x 2, del3 is of order 1 x 1 and z2 is of the order 1 x 2. How do I matrix multiply del3.W2 and sigmoidPrime(z2) ? (P.S. I was not implementing it in python) and thanks in advance.

@RSKothari
Copy link

Hey Kenway, since no has replied back to you yet, I'll try and help.

np.dot is a matrix multiplication while * is an element wise product. So, if you have followed his notes by the line, the final matrix multiplication for djdw1 will be ([3XN]. ([NX2].[2X4]) * [NX4]). I am sorry for not writing the math equation because I don't know how to over here.

He first gets it down to:
[3XN] . [NX4] * [NX4]

Then:
[3XN] . [NX4] = [3X4]

@mind-matrix
Copy link
Author

Oh... Ok. Now I see... Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants