Training Statistics¶
- qucumber.utils.training_statistics.KL(nn_state, target, space=None, bases=None, **kwargs)[source]¶
A function for calculating the KL divergence averaged over every given basis.
- Parameters
nn_state (qucumber.nn_states.NeuralStateBase) – The neural network state.
target (torch.Tensor or dict(str, torch.Tensor)) – The true state (wavefunction or density matrix) of the system. Can be a dictionary with each value being the state represented in a different basis, and the key identifying the basis.
space (torch.Tensor) – The basis elements of the Hilbert space of the system . The ordering of the basis elements must match with the ordering of the coefficients given in target. If None, will generate them using the provided nn_state.
bases (numpy.ndarray) – An array of unique bases. If given, the KL divergence will be computed for each basis and the average will be returned.
**kwargs – Extra keyword arguments that may be passed. Will be ignored.
- Returns
The KL divergence.
- Return type
- qucumber.utils.training_statistics.NLL(nn_state, samples, space=None, sample_bases=None, **kwargs)[source]¶
A function for calculating the negative log-likelihood (NLL).
- Parameters
nn_state (qucumber.nn_states.NeuralStateBase) – The neural network state.
samples (torch.Tensor) – Samples to compute the NLL on.
space (torch.Tensor) – The basis elements of the Hilbert space of the system . If None, will generate them using the provided nn_state.
sample_bases (numpy.ndarray) – An array of bases where measurements were taken.
**kwargs – Extra keyword arguments that may be passed. Will be ignored.
- Returns
The Negative Log-Likelihood.
- Return type
- qucumber.utils.training_statistics.fidelity(nn_state, target, space=None, **kwargs)[source]¶
Calculates the square of the overlap (fidelity) between the reconstructed state and the true state (both in the computational basis).
- Parameters
nn_state (qucumber.nn_states.NeuralStateBase) – The neural network state.
target (torch.Tensor) – The true state of the system.
space (torch.Tensor) – The basis elements of the Hilbert space of the system . The ordering of the basis elements must match with the ordering of the coefficients given in target. If None, will generate them using the provided nn_state.
**kwargs – Extra keyword arguments that may be passed. Will be ignored.
- Returns
The fidelity.
- Return type