Is it possible to use ignite with torchtext similar to the MNIST example here 1? In this example, once you have constructed your DataLoader and model, the code is essentially
model = Net()
opt = optim.SGD(model.parameters(), lr=0.01)
criterion = nn.NLLLoss()

trainer = create_supervised_trainer(model, opt, criterion)
trainer.run(data_loader, max_epochs=10)

with some additional for logging if desired.
If you follow an example from torchtext with a similar “input-output” structure such as this one 2
TEXT = data.Field()
LABELS = data.Field()

train, val, test = data.TabularDataset.splits(
    path='/data/pos_wsj/pos_wsj', train='_train.tsv',
    validation='_dev.tsv', test='_test.tsv', format='tsv',
    fields=[('text', TEXT), ('labels', LABELS)])

train_iter, val_iter, test_iter = data.BucketIterator.splits(
    (train, val, test), batch_sizes=(16, 256, 256),
    sort_key=lambda x: len(x.text), device=0)

TEXT.build_vocab(train)
LABELS.build_vocab(train)

In this case, as far as I can tell, you can’t pass train_iter to trainer as written above because each batch from train_iter is not a tuple as is in the MNIST case. Is there a way to accommodate this difference with ignite?