1

I think there is an error in line 53 of the following code:

CycleGan, Buffer for Images

It says:

return_images = torch.cat(return_images, 0)  # collect all the images and return

What do you think, what should it read correctly? After having gone throught the code, I am unfortunately not sure what this specific line is supposed to do, but I think I understand the rest until line 52.

1 Answers1

1

torch.cat's first argument is expected to be a sequence of tensors rather than a single tensor. So you pass in like:

torch.cat([tensor_1, tensor_2, tensor_3])       # the right way

instead of

torch.cat(tensor_1, tensor_2, tensor_3)         # not the right way

In the code you linked, they are forming a list called return_images which contains many tensors in it.

np.concatenate has the same behaviour too and PyTorch designers probably mimicked the choice from there. ("cat" is short for "concatenate" which is hard to write!).

Mustafa Aydın
  • 17,645
  • 4
  • 15
  • 38
  • May I ask: Do you think you could also help me with this [PyTorch-related question](https://stackoverflow.com/questions/66831061/embedding-layer-in-python-how-to-use-correctly-with-torchsummary)? – Hulio Almedo Mar 27 '21 at 17:44
  • @HulioAlmedo Glad to be of help! I left a comment there that *i think* solves that problem. (but i'm not familiar with GANs and not good at embeddings, so any error after that, I might not be able to answer :)) – Mustafa Aydın Mar 27 '21 at 18:09