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

Potential error in the derivation for backpropagation through through time in RNNs #2616

Open
faerryn opened this issue Aug 28, 2024 · 0 comments

Comments

@faerryn
Copy link

faerryn commented Aug 28, 2024

We believe there is an error with section 9.7.2: Backpropagation Through Time in Detail, and would like to ask for clarification, and we would like to help fix the error if it indeed is present. This issue was researched by myself, @ishaanharry, and @Calcu-dev, with guidance from our course instructor. The text of this issue was primarily authored by @ishaanharry.

The text notes that

image1

Thus as an intermediate step to computing dL/dW_hx and dL/dW_hh, dh_t/dW_hx and dh_t/dW_hh must be computed.

The text equates the above expressions to these, which implies that dh_t/dW_hx = x_t^T and dh_t/dW_hh = h_{t-1}^T

image2

However, this cannot be correct, as can be seen upon reviewing the expression for h_t.

image3

Observe that h_t contains the term h_{t-1}, so this is a telescopic function that rolls out until the initial value. What's important to note is that each telescoping term contains another W_hx and W_hh, so the derivative of h_t w.r.t either of the weight matrices must have multiple terms, not simply x_t^T or h_{t-1}^T.

The textbook even states this in a prior section. In 9.7.1: Analysis of Gradients in RNNs, the text derived dh_t/dw_h using the rollout I described earlier, with h_t being a generalized function of x_t, h_{t-1}, and w_h.

image5

So applying this to the earlier derivation of dL/dW_hx and dL/dW_hh, we should get

image4

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

1 participant