The code is working properly when I use RGB images, so I think there is no errors with the code.
sorry, I am still new to Pytorch, I dont know what is self.inplanes for. But it exist in resnet18 code.