pclucas14 / pixel-cnn-pp

Pytorch Implementation of OpenAI's PixelCNN++
Other
345 stars 76 forks source link

Can I change the input to a normal picture instead of zeros? #16

Closed ZhangXGe closed 4 years ago

ZhangXGe commented 4 years ago

Will output be similar to input if input is a normal picture like one cifar picture ?

pclucas14 commented 4 years ago

I'm not sure I understand your question. If you feed a 32x32x3 cifar picture to the network, it will output a tensor 32x32xD where at index [i,j] you have the conditional probability p(x_ij| x_{i,j-1}, ...., x_{0,0}). So yes, for a trained model, you would probably get an output that is very close to the original picture

ZhangXGe commented 4 years ago

Thanks , that's what I mean.But when input is a cifar picture and sample_batch_size=1 ,the output is too poor to recognize. Is that normal?

pclucas14 commented 4 years ago

1) did you train the model and 2) how did you obtain a 32 x 32 x 3 from the 32 x 32 x D output ?

ZhangXGe commented 4 years ago

1.I used pretrained models '589' and '889'. 2.I only change this codedata = torch.zeros(sample_batch_size, obs[0], obs[1], obs[2]) to data = trans(img) data = torch.unsqueeze(data,0),img is a cifar image.

pclucas14 commented 4 years ago

You don't want to run the nested loops (lines 103 104) here since you are teacher forcing. Once you have data try simply doing

data_v = Variable(data, volatile=True)
out = model(data_v, sample=True)
out_sample = sample_op(out)
ZhangXGe commented 4 years ago

Ok,i will try it.Thanks very much for answering my questions.