Yup, that’s what I am doing. I am loading a .npz file and encoding it.This is the code:
img = np.load('/HMI20181101_0000_bz.npz', allow_pickle=True)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
train_img = img['x']
train_img = train_img.reshape(1, 1, 512, 512)
train_img = np.array(train_img, dtype=np.float)
train_img = torch.from_numpy(train_img)
train_img = train_img.to(device, dtype=torch.float)

res = encoder(train_img)

This is my model for the encoder:
ModuleList(
  (0): DownConv(
    (conv1): Conv2d(1, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (conv2): Conv2d(8, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  )
  (1): DownConv(
    (conv1): Conv2d(8, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (conv2): Conv2d(16, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  )
  (2): DownConv(
    (conv1): Conv2d(16, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (conv2): Conv2d(32, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  )
  (3): DownConv(
    (conv1): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  )
  (4): DownConv(
    (conv1): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  )
)

And the error I get after running the code is:


TypeError                                 Traceback (most recent call last)
 in 
----> 1 res = encoder(train_img)
~/anaconda3/envs/work/lib/python3.8/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
548             result = self._slow_forward(*input, **kwargs)
549         else:
–> 550             result = self.forward(*input, **kwargs)
551         for hook in self._forward_hooks.values():
552             hook_result = hook(self, input, result)
TypeError: forward() takes 1 positional argument but 2 were given

I have attached the model 2 so you can try it out. And the weights from here