Forward Pass: While Loop #1779
Answered
by
jheek
pharringtonp19
asked this question in
Q&A
-
How should I go about writing a while loop in the forward pass of a neural network? In my naive implementation, I run into the error that " Module instance is frozen outside of setup method."
|
Beta Was this translation helpful? Give feedback.
Answered by
jheek
Jan 12, 2022
Replies: 1 comment 1 reply
-
Are you sure you want iterations to be a mutating field of MLP instead of a local variable in |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pharringtonp19
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are you sure you want iterations to be a mutating field of MLP instead of a local variable in
__call__
?Also you are calling nn.Dense inside the while loop which means you create a new Dense (with it's own params) each iteration. Are you sure you don't want param sharing and create the nn.Dense instance before entering the while loop?