pytorch / ignite

High-level library to help with training and evaluating neural networks in PyTorch flexibly and transparently.
https://pytorch-ignite.ai
BSD 3-Clause "New" or "Revised" License
4.51k stars 611 forks source link

Global settings [Prospective] #881

Open sdesrozis opened 4 years ago

sdesrozis commented 4 years ago

šŸš€ Feature

The idea is to provide a global settings tool to help the configuration

ignite.settings["log_interval"] = 10
ignite.settings["with_pbar"] = True
ignite.settings["device"] = "cuda"

and

# Here device used from settings
metrics = {"accuracy": Accuracy(), "loss": Loss(criterion)}
evaluator = create_supervised_evaluator(model, metrics=metrics)

Parameters passed to method are used in priority

accuracy_on_cpu = Accuracy(device="cpu")
ritzvik commented 4 years ago

@sdesrozis I know a repo which uses .cfg file for configuration. Check it out here . The file hyperlinked is the one responsible for handling global settings. With a little more clarity on this, I can proceed with working on it.

Thanks!

sdesrozis commented 4 years ago

Thank you for the rss šŸ˜Š I will try to clarify the idea thus we will discuss šŸ˜‰

ritzvik commented 4 years ago

Thank you for the rss šŸ˜Š I will try to clarify the idea thus we will discuss šŸ˜‰

Sure :)

sdesrozis commented 4 years ago

So, at the moment, there is no consensus in the team about this.

I suggest to propose APIs to help to bound the PR. What is clear from now is that we don't need to parse configuration files. Althought, thanks for the link :)

We prefer a settings dict in the ignite scope. How to define it and fill it is to be designed by APIs. This dict should be used in core tools (metrics, handlers, etc.) to help the configuration. How to use it (at dev level) is to be designed by APIs.

Look examples/references/classification/imagenet/code/scripts/common_training.py and see how this settings could help about :

This issue is quite prospective :)

vfdev-5 commented 4 years ago

Another config to put:

erip commented 4 years ago

It might be nice to use hydra for this (https://hydra.cc). I have some experience with this and it makes things pretty easy.

sdesrozis commented 4 years ago

It might be nice to use hydra for this (https://hydra.cc). I have some experience with this and it makes things pretty easy.

@erip thank you šŸ™šŸ» Could you write some example codes to show how hydra could be used with ignite ? Iā€™m very curious šŸ˜

erip commented 4 years ago

I'm happy to give it a try! Since it's kind of involved, I'll create a working example in a separate repo and link it here. We can discuss the API and any potential limitations here.

sdesrozis commented 4 years ago

We discussed a lot about settings and we definitely need to experiment !

google/gin-config is another tools which could be great (but another language...)