Hi!
I am unable to get the parameter that I had created in the def __init__(self): function the parameter is : self.q_params = nn.Parameter(q_delta * torch.randn(train_Rdepth * n_qubits, requires_grad=True))
import torch.nn as nn
import torch.nn.functional as F


class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 6, 5)
        #self.conv1 = self.conv1.to(device)

        self.pool = nn.MaxPool2d(2, 2)
        #self.pool = self.pool.to(device)

        self.conv2 = nn.Conv2d(6, 8, 6)
        #self.conv2 = self.conv2.to(device)

        self.q_params = nn.Parameter(q_delta * torch.randn(train_Rdepth * n_qubits, requires_grad=True))
        #self.q_params = self.q_params.to(device)

        #print(self.q_params.requires_grad)
        #self.q_params = torch.nn.ModuleList(self.q_params)

        self.fc1 = nn.Linear(1 * 4 * 4, 120)
        self.fc1 = self.fc1.to(device)
        self.fc2 = nn.Linear(120, 84)
        self.fc2 = self.fc2.to(device)
        self.fc3 = nn.Linear(84, 10)
        self.fc3 = self.fc3.to(device)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        #print(x.shape)
        #print(type(x))
        #print(x)
        pre_out = x 

        q_in = torch.tanh(pre_out) * np.pi / 2.0   
        
        # Apply the quantum circuit to each element of the batch, and append to q_out
        #q_out = torch.Tensor(0, n_qubits)
        q_out = torch.Tensor(0,1, q_in.shape[2], q_in.shape[3])
        q_out = q_out.to(device)
        for elem in q_in:
            # q_out_elem = q_net(elem,self.q_params).float().unsqueeze(0)
            q_out_elem = torch.from_numpy(q_net(elem,self.q_params)).float()
            q_out = torch.cat((q_out, q_out_elem.to(device).reshape((1,1,q_in.shape[2], q_in.shape[3]))))
       
        x = q_out.to(device)
        x = x.view(-1, 1 * 4 * 4)
        #x = x.to(device)
        #self.hidden = torch.nn.ModuleList(self.hidden)
        x = F.relu(self.fc1(x))
        #x = x.to(device)
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x


net = Net()

The output from net.parameters() is :
<bound method Module.parameters of Net(
  (conv1): Conv2d(3, 6, kernel_size=(5, 5), stride=(1, 1))
  (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  (conv2): Conv2d(6, 8, kernel_size=(6, 6), stride=(1, 1))
  (fc1): Linear(in_features=16, out_features=120, bias=True)
  (fc2): Linear(in_features=120, out_features=84, bias=True)
  (fc3): Linear(in_features=84, out_features=10, bias=True)
)>

You can see that the parameter I had created is not present in the output so even if I pass into my :
import torch.optim as optim

criterion = nn.CrossEntropyLoss()
optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)

So my self.q_params will not train…
Can anybody help to resolve this issue?