Different Optimisers In Different Layers


I am currently looking into hybrid neural networks. I would like to apply a different optimizer to quantum circuit compared to the classical layers.

The quantum circuit has classical input and parameters so it can be optimised by an classical optimiser.

My network looks like

class NeuralNet(nn.Module)

  def __init__(self):
    super(NeuralNet, self).__init__()
    self.pre_net = nn.Linear(28*28, 4)
    self.q_params = nn.Parameter(0.01 * torch.randn(q_depth * 4)) #Quantum circuit parameters 
    self.post_net = nn.Linear(4, 10)

1.) How can I apply the same optimiser to all layers, but have a different step size for the quantum circuit parameters

2.) How can I apply a completely different optimiser to the quantum circuit parameters?

Thanks for your help


You could pass only a subset to the corresponding optimizers.
This per-param example shows how to use different arguments for specific parameter sets, but you could use the syntax to create two optimizers with different parameters.

Thanks for the reply! Could you possibly provide a quick example for the two optimiser case?

Really appreciate the help :grinning: