Trace of the state for CV QNodes


#1

hi,
in this notebook i changed the scale of the output and divided it by 10000. i.e Y was divided by 10000.
and when i tried to run it again the optimization started way far from the minima but the trace was still 0.99. when I started tracking the gradients and the output from the NN itself i noticed that with bigger weights the circuit’s output becomes smaller and hence the optimization starts within a reasonable position away from the minima. however the trace becomes “0.0005” very small and i think this means that the simulation in the Fock basis is not healthy at all and yet it still converges and gives better results. I then tried to increase the number of layers “10” instead of “4” and lowered the weights a bit i just made the variance equal one and the optimization started a bit far but within a reasonable time it converges and the trace was not perfectly 1 but al least much bigger than zero.
is that normal behaviour? @josh @Maria_Schuld


#2

Yes, that’s a common hassle with the CV models and the fock backend. It’s always good to monitor the trace! Otherwise the cost function drives the optimization to an artificial regime that’s actually not physical.

Essentially (as you may have guessed) the squeezing and displacement amplitudes are the problem, if they are kept sufficiently low you should be fine. A good strategy is to add a penalty term for those weights to the cost function. Normal L2 regularisation will also do…


#3

Thanks for your response.
So i guess the target values should be scaled properly to overcome the trace problem


#4

@Maria_Schuld
based on my experience with CV models up until now
the cutoff dimension actually helps a lot more than the L2 reg.
I found that increasing it makes the convergence a bit slow but much more stable and also the whole regime stays in a healthy quantum state as long as the weights are initialized with a very small variance and the features “input,target” are scaled properly
and again thanks so much for this discussion