tfq.math.mps_1d_sampled_expectation
Stay organized with collections
Save and categorize content based on your preferences.
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).
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-05-17 UTC.
[null,null,["Last updated 2024-05-17 UTC."],[],[],null,["# tfq.math.mps_1d_sampled_expectation\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/quantum/blob/v0.7.3/tensorflow_quantum/core/ops/math_ops/simulate_mps.py#L107-L152) |\n\nCalculate the expectation value of circuits using samples.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tfq.math.simulate_mps.mps_1d_sampled_expectation`](https://www.tensorflow.org/quantum/api_docs/python/tfq/math/mps_1d_sampled_expectation)\n\n\u003cbr /\u003e\n\n tfq.math.mps_1d_sampled_expectation(\n programs, symbol_names, symbol_values, pauli_sums, num_samples, bond_dim=4\n )\n\nSimulate the final state of `programs` given `symbol_values` are placed\ninside of the symbols with the name in `symbol_names` in each circuit.\nThem, sample the resulting state `num_samples` times and use these samples\nto compute expectation values of the given `pauli_sums`. Note that this op\nrequires 1D non periodic circuits.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `programs` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of strings with shape \\[batch_size\\] containing the string representations of the circuits to be executed. |\n| `symbol_names` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/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`. |\n| `symbol_values` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/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`. |\n| `pauli_sums` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/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. |\n| `num_samples` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/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`. |\n| `bond_dim` | Integer value used for the bond dimension during simulation. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/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). ||\n\n\u003cbr /\u003e"]]