stargan-v2 icon indicating copy to clipboard operation
stargan-v2 copied to clipboard

About selecting the style codes

Open Nick-Sun1018 opened this issue 4 years ago • 2 comments

out = torch.stack(out, dim=1) # (batch, num_domains, style_dim) idx = torch.LongTensor(range(y.size(0))).to(y.device) s = out[idx, y] # (batch, style_dim)

Thank you for your excellent works, I have a question about the code above. This part is from model.py, class StyleEncoder, how does s=out[idx, y] work? Don't we get the s equals to one of the element of h before stacking? I'll be very appreciated if you reply!

Nick-Sun1018 avatar Dec 23 '20 02:12 Nick-Sun1018

Hi, y holds indices for the target domain which should be the same with the reference images. idx is an enumeration of indices over the minibatch, i.e., [0, 1, ... B] where B = batch size. out before stacking is list of outputs for each domains, which are in shape of (B, style_dim). We added 'stacking and indexing' procedure to collect style vectors from the target domains. Does this answer your question?

youngjung avatar Dec 24 '20 03:12 youngjung

Yes, I understand, Thank you for your elaboration!

Nick-Sun1018 avatar Dec 24 '20 07:12 Nick-Sun1018