agrimgupta92 / sgan

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

Question: Training error #15

Closed daehoumich closed 5 years ago

daehoumich commented 5 years ago

While running training, this error happened~!

Traceback (most recent call last): File "scripts/train.py", line 580, in main(args) File "scripts/train.py", line 148, in main batch_norm=args.batch_norm) File "/home/daeho/sgan-master/sgan/models.py", line 425, in init if self.noise_dim[0] == 0:

Should I change noise_dim?

daehoumich commented 5 years ago

TypeError: 'NoneType' object is not subscriptable

angeliand commented 5 years ago

You should most likely make noise_dim equal to 0 with the command line flags (--noise_dim=0).

The error occurs because as you can see in this line of code : if self.noise_dim[0] == 0: noise_dim gets indexed. However the default value for noise_dim (see TRAINING.MD for this) is None, which cannot be indexed. Arrays, lists, etc. can be.

It's a slight inconvenience in the code which could be avoided by making the default value 0.

rowanmcallister commented 5 years ago

Why was this issue closed, without fixing the code?

I ran into the same issue 4 months on.

w00zie commented 5 years ago

I don't want to

make noise_dim equal to 0 with the command line flags

as @angeliand pointed out. I want to add noise while training, as @agrimgupta92 did while training his models. I used his script print_args.py and noticed how he consistently trained with noise_dim = 8. I've tried to add noise with --noise_dim 8 but that resulted in this error:

Traceback (most recent call last):
  File "scripts/train.py", line 643, in <module>
    main(args)
  File "scripts/train.py", line 271, in main
    optimizer_d)
  File "scripts/train.py", line 399, in discriminator_step
    generator_out = generator(obs_traj, obs_traj_rel, seq_start_end)
  File "anaconda3/envs/progetto/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "sgan/sgan/models.py", line 587, in forward
    seq_start_end,
  File "anaconda3/envs/progetto/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 175, in forward
    self.check_forward_args(input, hx, batch_sizes)
  File "anaconda3/envs/progetto/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 152, in check_forward_args
    'Expected hidden[0] size {}, got {}')
  File "anaconda3/envs/progetto/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 148, in check_hidden_size
    raise RuntimeError(msg.format(expected_hidden_size, tuple(hx.size())))

Thanks.

mingbocui commented 5 years ago

@w00zie Hi, have you solved this problem? I also want to train with non-zero noise-dim, thanks in advance!

mingbocui commented 5 years ago

@w00zie seems that I could run the code now, just change (8,0) to 8

w00zie commented 5 years ago

@mingbocui you mean --noise_dim 8 or --noise_dim (8,0)? Thank you

mingbocui commented 5 years ago

@w00zie just use --noise_dim 8