tfq.append_circuit

View source on GitHub

Merge programs in the input tensors.

tfq.append_circuit(
 programs, programs_to_append
)

Given two tensors of programs, this function merges the programs pairwise and returns a single tensor containing the merged programs. Note that this function is not differentiable because the output has type string.

q = cirq.GridQubit(0, 0)
p0 = [cirq.Circuit(cirq.H(q)), cirq.Circuit(cirq.S(q))]
p1 = [cirq.Circuit(cirq.Z(q)), cirq.Circuit(cirq.X(q))]
p0_t = tfq.convert_to_tensor(p0)
p1_t = tfq.convert_to_tensor(p1)
tfq.from_tensor(append_circuit(p0_t, p1_t))
array([cirq.Circuit([
 cirq.Moment(
 cirq.H(cirq.GridQubit(0, 0)),
 ),
 cirq.Moment(
 cirq.Z(cirq.GridQubit(0, 0)),
 ),
]),
 cirq.Circuit([
 cirq.Moment(
 cirq.S(cirq.GridQubit(0, 0)),
 ),
 cirq.Moment(
 cirq.X(cirq.GridQubit(0, 0)),
 ),
])], dtype=object)

Args

programs tf.Tensor of strings with shape [batch_size] containing the string representations of circuits.
programs_to_append tf.Tensor of strings with shape [batch_size] containing the string representations of circuits to append.

Returns

tf.Tensor with shape [batch_size]. Entry i is the string representing the circuit which is programs_to_append[i] appended to programs[i].

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.