Calculate the expectation value of circuits using samples.
tfq.math.mps_1d_sampled_expectation(
programs, symbol_names, symbol_values, pauli_sums, num_samples, bond_dim=4
)
Simulate the final state of programs
given symbol_values
are placed
inside of the symbols with the name in symbol_names
in each circuit.
Them, sample the resulting state num_samples
times and use these samples
to compute expectation values of the given pauli_sums
. Note that this op
requires 1D non periodic circuits.
Args |
programs
|
tf.Tensor of strings with shape [batch_size] containing
the string representations of the circuits to be executed.
|
symbol_names
|
tf.Tensor of strings with shape [n_params], which
is used to specify the order in which the values in
symbol_values should be placed inside of the circuits in
programs .
|
symbol_values
|
tf.Tensor of real numbers with shape
[batch_size, n_params] specifying parameter values to resolve
into the circuits specificed by programs, following the ordering
dictated by symbol_names .
|
pauli_sums
|
tf.Tensor of strings with shape [batch_size, n_ops]
containing the string representation of the operators that will
be used on all of the circuits in the expectation calculations.
|
num_samples
|
tf.Tensor with num_samples[i][j] is equal to the
number of samples to draw in each term of pauli_sums[i][j]
when estimating the expectation. Therefore, num_samples must
have the same shape as pauli_sums .
|
bond_dim
|
Integer value used for the bond dimension during simulation.
|
Returns |
tf.Tensor with shape [batch_size, n_ops] that holds the
expectation value for each circuit with each op applied to it
(after resolving the corresponding parameters in).
|