facebookresearch / ParlAI

A framework for training and evaluating AI models on a variety of openly available dialogue datasets.
https://parl.ai
MIT License
10.48k stars 2.09k forks source link

Error when running DrQA PyTorch 1.0.0 #1441

Closed isaacmg closed 5 years ago

isaacmg commented 5 years ago

When running the basic example on SQUAD python examples/train_model.py -m drqa -t squad -bs 32 Throwing this.

/content/DuReader/data/ParlAI/parlai/agents/drqa/layers.py:177: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  alpha_flat = F.softmax(scores.view(-1, y.size(1)))
/content/DuReader/data/ParlAI/parlai/agents/drqa/layers.py:237: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  alpha = F.softmax(scores)
/content/DuReader/data/ParlAI/parlai/agents/drqa/layers.py:210: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
  alpha = F.log_softmax(xWy)
Traceback (most recent call last):
  File "examples/train_model.py", line 16, in <module>
    TrainLoop(opt).train()
  File "/content/DuReader/data/ParlAI/parlai/scripts/train_model.py", line 500, in train
    world.parley()
  File "/content/DuReader/data/ParlAI/parlai/core/worlds.py", line 641, in parley
    batch_act = self.batch_act(agent_idx, batch_observations[agent_idx])
  File "/content/DuReader/data/ParlAI/parlai/core/worlds.py", line 614, in batch_act
    batch_actions = a.batch_act(batch_observation)
  File "/content/DuReader/data/ParlAI/parlai/agents/drqa/drqa.py", line 227, in batch_act
    self.model.update(batch)
  File "/content/DuReader/data/ParlAI/parlai/agents/drqa/model.py", line 102, in update
    self.train_loss.update(loss.data[0], ex[0].size(0))
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

I think this is related to the new version of PyTorch and the fix should be fairly trivial. Anyone working on fixing it soon? If not I could probably do a PR.

stephenroller commented 5 years ago

Thanks for pointing out!

One of us will fix this eventually, but a PR would be the fastest way to fix.