Closed daehoumich closed 5 years ago
TypeError: 'NoneType' object is not subscriptable
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.
Why was this issue closed, without fixing the code?
I ran into the same issue 4 months on.
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())))
noise_dim = 0
leads to a model trained on real data only (with no added noise at all) ?Thanks.
@w00zie Hi, have you solved this problem? I also want to train with non-zero noise-dim, thanks in advance!
@w00zie seems that I could run the code now, just change (8,0) to 8
@mingbocui you mean --noise_dim 8
or --noise_dim (8,0)
?
Thank you
@w00zie just use --noise_dim 8
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?