Thank you a lot! I did not use transform because now I am dealing with array and tensor instead of image. After I use torch.from_numpy(img).float() this error is going. However another error coming up:
loss : 6.1917, time : 0.4663
Traceback (most recent call last):
  File "maintxt1.py", line 240, in <module>
    output = model(input)
  File "/home/tangyeping/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/tangyeping/pixel-cnn-pp/model.py", line 119, in forward
    x = x if sample else torch.cat((x, self.init_padding), 1)
RuntimeError: Sizes of tensors must match except in dimension 3. Got 184 and 148

I have met this error before when using image object. And after I apply transforms.Resize(size=(16,224)) the error is gone. Is there anything similar I can do with tensor or numpy array to fix it? Or is there another source of error?