jondeuce / Ignite.jl

MIT License
26 stars 1 forks source link

Add doc “real examples” (to display a complete efficient workflow) #5

Open dmetivie opened 1 year ago

dmetivie commented 1 year ago

I understand the use of this package and want to use it. I got the well written README examples. However, I am wondering how one would generalize some stuff to real problem without performance issues:

  1. How should arguments be passed to the trainer ? Like rng, hyperparams, should it be global variables ? I thought this lead to performance issues. Generally, I was also wondering if using Ignite.jl lead to performance change.
  2. Similarly, should all the add_event_handler be passed into a single function returning trainer? So that one just have to run!
  3. What are the keyword possible for Ignite.run!
  4. Example where the loss is saved every 10 steps for later plotting (I think I know how to do this one)

Of course, I can try to contribute to provide examples, but to get started I think I need at least to be clear on point 1. and 2.

jondeuce commented 1 year ago
  1. Yes, Ignite is designed to be used in Python-style scripting, with models etc. stored as globals. This does have a small performance penalty, but in general for moderately sized models the overhead is negligible. Of course you can wrap the whole script in a main() function to avoid globals, too. Ignite itself typically has very little (~10us) overhead.
  2. That is a fine approach yes. Note that add_event_handler! is just a regular function, and it's first argument in the examples is just a regular closure capturing (global) variables.
  3. See the docs
  4. You just need to make an event that fires every 10 iterations and caches engine.output in the state, e.g. push!(engine.state.losses, engine.output). See the docs for engine.state