def apply_operator(dtype): """Apply the initial_state operator""" a = tf.zeros(10, dtype=dtype) return op.initial_state(a)
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
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
def grad_custom(var): with tf.GradientTape() as tape: loss = custom_operators.initial_state(var) return tape.gradient(loss, var)