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

Chapter 5: weight_deltas calculation in case of multiple inputs and multiple outputs #23

Open
dimchansky opened this issue Aug 31, 2019 · 3 comments

Comments

@dimchansky
Copy link
Contributor

weight_deltas are calculated in this way:

[ [input[0] * delta[0], input[0] * delta[1], input[0] * delta[2]],
  [input[1] * delta[0], input[1] * delta[1], input[1] * delta[2]],
  [input[2] * delta[0], input[2] * delta[1], input[2] * delta[2]] ]

but should be transposed:

[ [input[0] * delta[0], input[1] * delta[0], input[2] * delta[0]],
  [input[0] * delta[1], input[1] * delta[1], input[2] * delta[1]],
  [input[0] * delta[2], input[1] * delta[2], input[2] * delta[2]] ]

otherwise weights are updated incorrectly.

Current code:

import numpy as np
def outer_prod(a, b):
    
    # just a matrix of zeros
    out = np.zeros((len(a), len(b)))

    for i in range(len(a)):
        for j in range(len(b)):
            out[i][j] = a[i] * b[j]
    return out

weight_deltas = outer_prod(input,delta)

PR should fix the issue: #22

@dimchansky
Copy link
Contributor Author

@iamtrask but in fact, the code proposed in the book seems difficult to understand. I think it would be much clearer to write it just like this:

weight_deltas = [ele_mul(d,input) for d in delta]

@PeterGanZW
Copy link

I second this. The weight_delta matrix should have the same number of columns as the length of the "input" vector. It should be

weight_deltas = outer_prod(delta,input).

@dimchansky
Copy link
Contributor Author

dimchansky commented Feb 11, 2020

I second this. The weight_delta matrix should have the same number of columns as the length of the "input" vector. It should be

weight_deltas = outer_prod(delta,input).

@PeterGanZW Yep, I proposed the same changes in PR: #22

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