Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: stack(): argument 'tensors' (position 1) must be tuple of Tensors, not NoneType #5

Open
zhenzi0322 opened this issue Nov 9, 2023 · 6 comments

Comments

@zhenzi0322
Copy link

训练时出现如下问题:

Traceback (most recent call last):
  File "train.py", line 220, in <module>
    main()
  File "train.py", line 216, in main
    train(args, cfg)
  File "train.py", line 209, in train
    trainer.train(trn_loader, st_step, cfg["iter"], component_objects, chars_sim_dict)
  File "/app/trainer/combined_trainer.py", line 78, in train
    out_1, style_components_1 = self.gen.read_decode(trg_style_ids, trg_sample_index,
  File "/app/model/generator.py", line 69, in read_decode
    reference_feats = self.memory.read_chars(target_style_ids, trg_sample_index, reduction=reduction)
  File "/app/model/memory.py", line 90, in read_chars
    sc_feat = read_char(style_id, sample_index, reduction)
  File "/app/model/memory.py", line 49, in read_char
    comp_feat = self.read_point(style_id, sample_index, reduction)
  File "/app/model/memory.py", line 41, in read_point
    return torch.stack(sc_feats)
TypeError: stack(): argument 'tensors' (position 1) must be tuple of Tensors, not NoneType
@awei669
Copy link
Owner

awei669 commented Nov 10, 2023

你好,是否可以提供更多的报错信息?

看起来是这一步出问题了:
reference_feats = self.memory.read_chars(target_style_ids, trg_sample_index, reduction=reduction)

可以检查一下这一步输出的特征纬度是否正确:
self.gen.encode_write_comb(in_style_ids, style_sample_index, in_imgs[0]) # [B*3,256,16,16]

@zhenzi0322
Copy link
Author

zhenzi0322 commented Nov 10, 2023

trainer/combined_trainer.py:

image

上图就是我本地中的输出

@awei669
Copy link
Owner

awei669 commented Nov 17, 2023

看起来是某一次sample的reference个数不足k(num shot)个,但不足k个的batch应该会被丢掉才对,建议你仔细观察得到风格特征过程中tensor的维度变化。

@zhenzi0322
Copy link
Author

一直没找到原因,我这边就是卡在这一步,训练不了

@Gabrielprogramist
Copy link

Were you able to solve the problem? If so, how?

一直没找到原因,我这边就是卡在这一步,训练不了

@zhenzi0322
Copy link
Author

Were you able to solve the problem? If so, how?

一直没找到原因,我这边就是卡在这一步,训练不了

I was the one who ran successfully before, but I'm not quite sure where the modifications were made

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants