tfq.append_circuit
Stay organized with collections
Save and categorize content based on your preferences.
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.
[null,null,["Last updated 2024-05-17 UTC."],[],[],null,["# tfq.append_circuit\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/quantum/blob/v0.7.3/tensorflow_quantum/core/ops/tfq_utility_ops.py#L22-L65) |\n\nMerge programs in the input tensors. \n\n tfq.append_circuit(\n programs, programs_to_append\n )\n\nGiven two tensors of programs, this function merges the programs pairwise\nand returns a single tensor containing the merged programs. Note that this\nfunction is not differentiable because the output has type string. \n\n q = cirq.GridQubit(0, 0)\n p0 = [cirq.Circuit(cirq.H(q)), cirq.Circuit(cirq.S(q))]\n p1 = [cirq.Circuit(cirq.Z(q)), cirq.Circuit(cirq.X(q))]\n p0_t = tfq.convert_to_tensor(p0)\n p1_t = tfq.convert_to_tensor(p1)\n tfq.from_tensor(append_circuit(p0_t, p1_t))\n array([cirq.Circuit([\n cirq.Moment(\n cirq.H(cirq.GridQubit(0, 0)),\n ),\n cirq.Moment(\n cirq.Z(cirq.GridQubit(0, 0)),\n ),\n ]),\n cirq.Circuit([\n cirq.Moment(\n cirq.S(cirq.GridQubit(0, 0)),\n ),\n cirq.Moment(\n cirq.X(cirq.GridQubit(0, 0)),\n ),\n ])], dtype=object)\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 circuits. |\n| `programs_to_append` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of strings with shape \\[batch_size\\] containing the string representations of circuits to append. |\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\\]. Entry `i` is the string representing the circuit which is `programs_to_append[i]` appended to `programs[i]`. ||\n\n\u003cbr /\u003e"]]