Esempio n. 1
0
 def apply_operator(dtype):
     """Apply the initial_state operator"""
     a = tf.zeros(10, dtype=dtype)
     return op.initial_state(a)
Esempio n. 2
0
 def _default_initial_state(self) -> tf.Tensor:
     """Creates the |000...0> state for default initialization."""
     zeros = tf.zeros(2**self.nqubits, dtype=DTYPES.get('DTYPECPX'))
     state = op.initial_state(zeros)
     return state
Esempio n. 3
0
 def default(cls, circuit: "DistributedCircuit"):
     """Creates the |000...0> state for default initialization."""
     state = cls(circuit)
     with tf.device(state.device):
         op.initial_state(state.pieces[0])
     return state
Esempio n. 4
0
 def grad_custom(var):
     with tf.GradientTape() as tape:
         loss = custom_operators.initial_state(var)
     return tape.gradient(loss, var)