agrimgupta92 / sgan

Code for "Social GAN: Socially Acceptable Trajectories with Generative Adversarial Networks", Gupta et al, CVPR 2018
MIT License
813 stars 261 forks source link

Training error TypeError: expected Tensor as element 1 in argument 0, but got tuple #49

Closed davidglavas closed 5 years ago

davidglavas commented 5 years ago

I try running the train.py script on a CPU and get the following error in the decoder's forward pass:

/Users/davidglavas/Documents/GitHub/Social-GAN/venv/bin/python /Users/davidglavas/Documents/GitHub/Social-GAN/scripts/trainCPU.py --delim tab --noise_dim=0
[INFO: trainCPU.py:  120]: Initializing train dataset
[INFO: trainCPU.py:  122]: Initializing val dataset
[INFO: trainCPU.py:  130]: There are 21.03125 iterations per epoch
[INFO: trainCPU.py:  154]: Here is the generator:
[INFO: trainCPU.py:  155]: TrajectoryGenerator(
  (encoder): Encoder(
    (encoder): LSTM(64, 64)
    (spatial_embedding): Linear(in_features=2, out_features=64, bias=True)
  )
  (decoder): Decoder(
    (decoder): LSTM(64, 128)
    (pool_net): PoolHiddenNet(
      (spatial_embedding): Linear(in_features=2, out_features=64, bias=True)
      (mlp_pre_pool): Sequential(
        (0): Linear(in_features=192, out_features=512, bias=True)
        (1): ReLU()
        (2): Linear(in_features=512, out_features=1024, bias=True)
        (3): ReLU()
      )
    )
    (mlp): Sequential(
      (0): Linear(in_features=1152, out_features=1024, bias=True)
      (1): ReLU()
      (2): Linear(in_features=1024, out_features=128, bias=True)
      (3): ReLU()
    )
    (spatial_embedding): Linear(in_features=2, out_features=64, bias=True)
    (hidden2pos): Linear(in_features=128, out_features=2, bias=True)
  )
  (pool_net): PoolHiddenNet(
    (spatial_embedding): Linear(in_features=2, out_features=64, bias=True)
    (mlp_pre_pool): Sequential(
      (0): Linear(in_features=128, out_features=512, bias=True)
      (1): ReLU()
      (2): Linear(in_features=512, out_features=1024, bias=True)
      (3): ReLU()
    )
  )
  (mlp_decoder_context): Sequential(
    (0): Linear(in_features=1088, out_features=1024, bias=True)
    (1): ReLU()
    (2): Linear(in_features=1024, out_features=128, bias=True)
    (3): ReLU()
  )
)
[INFO: trainCPU.py:  170]: Here is the discriminator:
[INFO: trainCPU.py:  171]: TrajectoryDiscriminator(
  (encoder): Encoder(
    (encoder): LSTM(64, 64)
    (spatial_embedding): Linear(in_features=2, out_features=64, bias=True)
  )
  (real_classifier): Sequential(
    (0): Linear(in_features=64, out_features=1024, bias=True)
    (1): ReLU()
    (2): Linear(in_features=1024, out_features=1, bias=True)
    (3): ReLU()
  )
)
[INFO: trainCPU.py:  234]: Starting epoch 1
Traceback (most recent call last):
  File "/Users/davidglavas/Documents/GitHub/Social-GAN/scripts/trainCPU.py", line 587, in <module>
    main(args)
  File "/Users/davidglavas/Documents/GitHub/Social-GAN/scripts/trainCPU.py", line 248, in main
    optimizer_d)
  File "/Users/davidglavas/Documents/GitHub/Social-GAN/scripts/trainCPU.py", line 376, in discriminator_step
    generator_out = generator(obs_traj, obs_traj_rel, seq_start_end)
  File "/Users/davidglavas/Documents/GitHub/Social-GAN/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/Users/davidglavas/Documents/GitHub/Social-GAN/sgan/models.py", line 656, in forward
    seq_start_end,
  File "/Users/davidglavas/Documents/GitHub/Social-GAN/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/Users/davidglavas/Documents/GitHub/Social-GAN/sgan/models.py", line 161, in forward
    [decoder_h.view(-1, self.h_dim), pool_h], dim=1)
TypeError: expected Tensor as element 1 in argument 0, but got tuple
davidglavas commented 5 years ago

The problem was that I added additional stuff to the return statement of the pooling module's forward function.