RSVP for your your local TensorFlow Everywhere event today!


Calculate the inner product between circuits.

Compute (potentially many) inner products between the given circuits and the symbol free comparison circuits.

Calculates out[i][j] = \langle \psi_{ ext{programs[i]} }
( ext{symbolvalues[i]}) | \psi{ ext{other_programs[j]} } angle

symbols = sympy.symbols('alpha beta')
qubits = cirq.GridQubit.rect(1, 2)
reference_circuits = [
        cirq.X(qubits[0]) ** symbols[0],
        cirq.Y(qubits[1]) ** symbols[1])
other_circuits = [
reference_tensor = tfq.convert_to_tensor(reference_circuits)
symbol_tensor = tf.convert_to_tensor(list(symbols))
values_tensor = tf.convert_to_tensor(np.arange(4).reshape(2, 2))
other_tensor = tfq.convert_to_tensor([other_circuits, other_circuits])
ip = tfq.math.inner_product(reference_tensor)
    [[ 0+0.j, 8.8871640e-01+0.3681184j,
     [ 0+0.j, 7.3223300e-02-0.17677669j,
       0-0.5j]],shape=(2, 3), dtype=complex64)

programs tf.Tensor of strings with shape [batch_size] containing the string representations of the circuits
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.
other_programs tf.Tensor of strings with shape [batch_size, n_others] containing the string representations of the circuits with which to compute the overlap on programs with. Must not contain any free symbols.

tf.Tensor with shape [batch_size, n_others] where out[i][j] is equal to the inner product of programs[i] with symbol_values[i] resolved in and other_programs[i][j].