View source on GitHub

Calculate the unitary matrix for the given circuits.

qubit = cirq.GridQubit(0, 0)
symbol = sympy.Symbol('alpha')
my_circuit = cirq.Circuit(cirq.H(qubit) ** symbol)
tensor_circuit = tfq.convert_to_tensor([my_circuit])
tfq.calculate_unitary(tensor_circuit, ['alpha'], [[0.2]])
<tf.RaggedTensor [
    [[(0.9720+0.0860j), (0.0675-0.2078j)],
     [(0.0675-0.2078j), (0.8369+0.5017j)]]]>

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 specified by programs, following the ordering dictated by symbol_names.

tf.RaggedTensor with shape [batch_size, 2n_qubits[i], 2n_qubits[i]] where n_qubits[i] is the number of qubits for program i in programs. Each entry corresponds to the unitary matrix that circuit enacts.