Skip to content

Can I add a neural network as an auxilary variable to the Theseus Layer? How? #285

Answered by luisenp
MickShen7558 asked this question in Q&A
Discussion options

You must be logged in to vote

HI @MickShen7558, thanks a lot for the question. One pattern that we are using in some of our applications is to have the TheseusLayer as part of a larger nn.Module class, and then use class membership to access neural features in custom cost functions. I tried to illustrate this idea in the code below which does it for a toy problem; do let me know if you have questions about it.

Alternatively, while you cannot pass a full neural net as an auxiliary variable, it's definitely possible to pass its parameters as individual aux vars and then update the model's state dict. However, this would be extremely clunky IMO.

Finally, the other pattern is that, when your cost function doesn't depend d…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MickShen7558
Comment options

Answer selected by mhmukadam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #284 on August 29, 2022 21:28.