Hi, I am writing the code given below:
# Quantum Generator
dev = qml.device("lightning.qubit", wires=num_qubits)
@qml.qnode(dev)
def quantum_generator (inputs, weights):
qml.templates.AngleEmbedding(inputs, wires=range(latent_size))
qml.templates.StronglyEntanglingLayers(weights, wires=range(num_qubits))
return [qml.expval(qml.PauliZ(wire)) for wire in range(num_qubits)]
# Classical Discriminator
class Discriminator(nn.Module):
def __init__(self):
super(Discriminator, self).__init__()
self.model = nn.Sequential(
nn.Linear(image_size * image_size * 3, hidden_size),
nn.LeakyReLU(0.2),
nn.Linear(hidden_size, hidden_size),
nn.LeakyReLU(0.2),
nn.Linear(hidden_size, 1),
nn.Sigmoid()
)
def forward(self, x):
x = x.view(x.size(0), -1)
return self.model(x)
# Initialize generator and discriminator
generator = quantum_generator
discriminator = discriminator(). to(device)
# Loss function and optimizer
criterion = nn.BCELoss()
optimizer_generator = optim.Adam(generator.parameters, lr=learning_rate, betas=(beta1, 0.999))
optimizer_discriminator = optim.Adam(discriminator.parameters(), lr=learning_rate, betas=(beta1, 0.999))
The issue I am having is with generator.parameters when I define the losses and optimizer. I am getting the following error:
AttributeError: 'QNode' object has no attribute 'parameters'
Is there any way to get trainable parameters in PennyLane