You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw that most functions used with Flux code are functions that call global variables/Flux structures. However, to work well in my case (particularly when using different scripts or looping between different networks and hence avoiding ambiguity), I directly provide the Flux models as an argument to my functions. This is nice but a potential downside is that this forces me to also provide the network in the dataset list during training... See the notebook for a (quickly written and probably messy) example.
My question is related to the later point: Is this a legit way of doing things, or is there a better way to provide models to functions?
Thanks in advance for any insights!
Charles.
The text was updated successfully, but these errors were encountered:
I am not sure about the question, but the short answer is that any model can be directly passed to another function as an argument. There are no requirements to use globals (in fact, you probably shouldn't for most cases). Please let us know if there is more to the question. If not, I'll close this in a few days.
Thanks for the reply ! I think this actually answers the question: it is thus legit to pass any model to another function.
I think at the time I was asking this question, I was worried that this could slow-down the training if the model was copied or anything like that in the memory when passed to the function. But now I understand that the model is just provided to the function and anything happening inside the function should update the model. So passing the model to functions should not slow down things I guess.
Exactly, models (or any structs) are passed by reference to other functions. The model weight arrays are mutable, so as long as you modify them in-place, there should be no copying happening.
Hi,
I am using Flux 0.8 on Julia 1.1.0 for a project where I have various equations embedded in functions. Here is an example notebook with a toy problem looking like my research problem.
I saw that most functions used with Flux code are functions that call global variables/Flux structures. However, to work well in my case (particularly when using different scripts or looping between different networks and hence avoiding ambiguity), I directly provide the Flux models as an argument to my functions. This is nice but a potential downside is that this forces me to also provide the network in the dataset list during training... See the notebook for a (quickly written and probably messy) example.
My question is related to the later point: Is this a legit way of doing things, or is there a better way to provide models to functions?
Thanks in advance for any insights!
Charles.
The text was updated successfully, but these errors were encountered: