qml.pytrees.PyTreeStructure¶
- class PyTreeStructure(type_=None, metadata=(), children=<factory>)[source]¶
Bases:
objectA pytree data structure, holding the type, metadata, and child pytree structures.
>>> op = qml.adjoint(qml.RX(0.1, 0)) >>> data, structure = qml.pytrees.flatten(op) >>> structure PyTreeStructure(AdjointOperation, (), [PyTreeStructure(RX, (Wires([0]), ()), [PyTreeStructure()])])
A leaf is defined as just a
PyTreeStructurewithtype_=None.Attributes
Whether or not the structure is a leaf.
Any metadata needed to reproduce the original object.
The type corresponding to the node.
- is_leaf¶
Whether or not the structure is a leaf.
- metadata = ()¶
Any metadata needed to reproduce the original object.
- type_ = None¶
The type corresponding to the node. If
None, then the structure is a leaf.
code/api/pennylane.pytrees.PyTreeStructure
Download Python script
Download Notebook
View on GitHub