qubiter.SEO_simulator_tf module

class qubiter.SEO_simulator_tf.SEO_simulator_tf(file_prefix, num_qbits, init_st_vec=None, **kwargs)[source]

Bases: qubiter.SEO_simulator.SEO_simulator

TF= TensorFlow

This class is a child of SEO_simulator. The class replaces numpy methods by TensorFlow (2.0, Eager) methods when those methods perform the state vector evolution. This allows those tf methods to be taped, and the tape to be run in reverse to calculate gradients.

At the beginning (in the constructor), the class converts the arrays in self.cur_st_vec_dict from numpy to tf.

Certain “interface” methods of the parent class were written assuming that the arrays of self.cur_st_vec_dict are numpy. Such methods call convert_tensors_to_numpy() at their beginning to convert the tf arrays to numpy. They also call convert_tensors_to_tf() at their end to convert the numpy tensors back to tf, the way they were upon starting the method.

__init__(file_prefix, num_qbits, init_st_vec=None, **kwargs)[source]


  • file_prefix (str) –
  • num_qbits (int) –
  • init_st_vec (StateVec) –
  • kwargs (dict) – keyword args of SEO_simulator

This method converts the arrays in cur_st_vec_dict from tensorflow to numpy.

Return type:None

This method converts the arrays in cur_st_vec_dict from numpy to tensorflow.

Return type:None

Overrides method in parent SEO_simulator.

Return type:None