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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-17 UTC."],[],[]]