I found a confused problem about parameter shape when I use CVNeuralNetLayers:
dev = qml.device('strawberryfields.fock', wires=2, cutoff_dim=10) def circuit(pars): CVNeuralNetLayers(*pars, wires=range(2)) @qml.qnode(dev) def quantum_neural_net(var, x1=None,x2=None): qml.Displacement(x1, 0.0, wires=0) qml.Displacement(x2, 0.0, wires=1) circuit(var) return qml.expval(qml.X(0)) init_pars=cvqnn_layers_all(n_layers=2, n_wires=2, seed= None) result = [quantum_neural_net(init_pars, x1=xlo,x2=xlo) for xlo in X] #X is dataset with shape (# of samples, 2) ValueError: could not broadcast input array from shape (2,1) into shape (2)
However, I tried number of wires 1,2,4 all return similar error. Only use 3 wires, it would work. I read the CVNeuralNetLayers documentation, I found the M =K when wires are 3.