Ignite: Passing a parameter to model's forward pass on an event

Created on 14 Dec 2018  路  6Comments  路  Source: pytorch/ignite

First of all, I'd like to thank you for that great library.

However, I couldn't achieve a solution of my problem. I should use a different approach during the training stage and the evaluation stage. In PyTorch I could do this like this:

````
for epoch in range(1, n_epochs + 1):
model.train()
for data, target in train_loader:
#bla bla
output = model(data, training = True)
#bla bla

model.eval()
for data, target in valid_loader:
    #bla bla
    output = model(data, training = False)
    #bla bla

````

How can I achieve this using Ignite library?

All 6 comments

you don't have to have that argument at all.

Each nn.Module has a self.training parameter that is set by model.train() and model.eval()

@furkan-kucuk please take a look at the quickstart and examples.
For more details you can consult the implementations of create_supervised_trainer and create_supervised_evaluator.

If you find out the quickstart unclear or cumbersome, please post your feedback here.

you don't have to have that argument at all.

Each nn.Module has a self.training parameter that is set by model.train() and model.eval()

Thanks for the tremendous and fastest answer ever! You totally solved my problem!

@furkan-kucuk please take a look at the quickstart. For more details you can consult the implementations of create_supervised_trainer and create_supervised_evaluator.

If you find out the quickstart unclear or cumbersome, please post your feedback here.

Thank you for fast answer. I really admire your work and thankful for it!

@furkan-kucuk you're welcome.

I'll close the issue as it was solved. Feel free to reopen if you needed more precisions on this question

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sudy picture Sudy  路  4Comments

elanmart picture elanmart  路  4Comments

vfdev-5 picture vfdev-5  路  3Comments

alykhantejani picture alykhantejani  路  3Comments

vfdev-5 picture vfdev-5  路  4Comments