carpedm20 / DiscoGAN-pytorch

PyTorch implementation of "Learning to Discover Cross-Domain Relations with Generative Adversarial Networks"
Apache License 2.0
1.08k stars 226 forks source link

How to start training?? #18

Open edwardcho opened 4 years ago

edwardcho commented 4 years ago

Hello Sir,

I downloaded your code and maps-dataset.. And when I started I met some error.

...
Traceback (most recent call last):
  File "main.py", line 41, in <module>
    main(config)
  File "main.py", line 33, in main
    trainer.train()
  File "/itsme/TESTBOARD/additional_networks/GAN/pytorch_DiscoGAN_carpedm20/trainer.py", line 247, in train
    format(step, self.max_step, l_d.data[0], l_g.data[0]))
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

Thanks..

CorvoOrc commented 4 years ago

You need to change from .data[0] to .item() (example: print("[{}/{}] Loss_D: {:.4f} Loss_G: {:.4f}".format(step, self.max_step, l_d.data.item(), l_g.data.item())))