I want to feed two-qubit gaussian states with covariance matrix into CVNeuralNetLayers. However, it returned error that " The input matrix is not square".
> dev = qml.device('strawberryfields.fock', wires=2, cutoff_dim=10)
@qml.qnode(dev)
def quantum_neural_net(pars,cm):
mean_vector=np.array([[0.0],
[0.0],
[0.0],
[0.0]])
cm=cm.reshape((4,4))
qml.GaussianState(mean_vector,cm,wires=range(2))
CVNeuralNetLayers(*pars,wires=range(2))
return qml.expval(qml.X(0))
#random pick a column with 16 elements in training dataset
cm_test=xtr[89]
result=quantum_neural_net(init_pars,cm_test))
ValueError: The input matrix is not square
I directly used sf.ops.Gaussian(cm_test) to check, which worked.
> import strawberryfields as sf
cm_test=xtr[89].reshape((4,4))
result=sf.ops.Gaussian(cm_test)
print("returned gaussian state",result)
Out: returned gaussian state Gaussian([[ 68.4229 0. 68.5705 0. ]
[ 0. 68.4229 0. -68.5705]
[ 68.5705 0. 68.9229 0. ]
[ 0. -68.5705 0. 68.9229]], [0. 0. 0. 0.])