Hey @kevinkawchak,
You can use the compute_decomposition
method that each operator has:
inputs = np.random.uniform(0, np.pi, size=(n_qubits,))
print(qml.AngleEmbedding.compute_decomposition(inputs, wires=range(n_qubits), rotation=qml.RY))
n_layers = 10
weights = np.random.uniform(0, np.pi, size=(n_layers, n_qubits))
print(qml.RandomLayers.compute_decomposition(weights, wires=range(n_qubits), ratio_imprim=0, imprimitive=qml.CNOT, rotations=[qml.RY], seed=42))
[RY(tensor(1.42790738, requires_grad=True), wires=[0]), RY(tensor(2.82650401, requires_grad=True), wires=[1]), RY(tensor(1.51604305, requires_grad=True), wires=[2]), RY(tensor(2.66255654, requires_grad=True), wires=[3])]
[RY(tensor(1.1522639, requires_grad=True), wires=[2]), RY(tensor(2.30919675, requires_grad=True), wires=[1]), RY(tensor(2.99291522, requires_grad=True), wires=[0]), RY(tensor(1.87356346, requires_grad=True), wires=[0]), RY(tensor(1.49890151, requires_grad=True), wires=[2]), RY(tensor(0.42741971, requires_grad=True), wires=[3]), RY(tensor(1.76770254, requires_grad=True), wires=[2]), RY(tensor(3.06895537, requires_grad=True), wires=[1]), RY(tensor(0.6608513, requires_grad=True), wires=[1]), RY(tensor(3.00064304, requires_grad=True), wires=[3]), RY(tensor(2.6624893, requires_grad=True), wires=[0]), RY(tensor(2.98035507, requires_grad=True), wires=[2]), RY(tensor(2.35717625, requires_grad=True), wires=[1]), RY(tensor(1.89289895, requires_grad=True), wires=[2]), RY(tensor(1.71322966, requires_grad=True), wires=[0]), RY(tensor(2.89751162, requires_grad=True), wires=[3]), RY(tensor(0.75892838, requires_grad=True), wires=[3]), RY(tensor(1.13771258, requires_grad=True), wires=[0]), RY(tensor(1.7231123, requires_grad=True), wires=[2]), RY(tensor(2.94940615, requires_grad=True), wires=[0]), RY(tensor(0.252351, requires_grad=True), wires=[1]), RY(tensor(0.16210348, requires_grad=True), wires=[3]), RY(tensor(0.78967891, requires_grad=True), wires=[0]), RY(tensor(0.86227181, requires_grad=True), wires=[1]), RY(tensor(2.77279583, requires_grad=True), wires=[2]), RY(tensor(0.64170049, requires_grad=True), wires=[1]), RY(tensor(0.4653104, requires_grad=True), wires=[3]), RY(tensor(0.73046264, requires_grad=True), wires=[1]), RY(tensor(2.32315717, requires_grad=True), wires=[0]), RY(tensor(0.86651552, requires_grad=True), wires=[1]), RY(tensor(1.60561273, requires_grad=True), wires=[3]), RY(tensor(2.40816571, requires_grad=True), wires=[1]), RY(tensor(1.53504934, requires_grad=True), wires=[2]), RY(tensor(2.62760047, requires_grad=True), wires=[0]), RY(tensor(2.28099916, requires_grad=True), wires=[3]), RY(tensor(2.67712636, requires_grad=True), wires=[3]), RY(tensor(2.15453193, requires_grad=True), wires=[1]), RY(tensor(1.13060742, requires_grad=True), wires=[3]), RY(tensor(1.84518167, requires_grad=True), wires=[0]), RY(tensor(2.49053654, requires_grad=True), wires=[0])]
From there you can just count the number of RY
operators . There are more elegant ways of doing this, but this is short and to the point