Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Description: Data #27

Closed
xleonplayz opened this issue Oct 31, 2024 · 0 comments · Fixed by #32
Closed

Class Description: Data #27

xleonplayz opened this issue Oct 31, 2024 · 0 comments · Fixed by #32
Assignees

Comments

@xleonplayz
Copy link
Contributor

Class: Data

The Data class is used to manage and process activation matrices for quantum circuits. It includes the following attributes and methods:

Attributes

  • qubits

    The number of qubits, which corresponds to the number of rows in the activation matrices.

  • depth

    The circuit depth, which corresponds to the number of columns in the matrices.

  • activation_matrices

    A list of three-dimensional activation matrices that represent the circuits.

Methods

  • get_data

    This method loads the values for qubits, depth, and activation_matrices from the file data.json.

    • If var/data.json cannot be found, it returns Error Code: 1028 - Data.json not found.
    • Additionally, it checks if var/train.json can be found; if not, it returns Error Code: 1029 - train.json not found.
  • return_matrices

    Returns the stored activation matrices.

    • Verifies that the activation matrices have the following properties:
      • Each matrix has a name.
      • The activation matrices have the format:
        • Number of rows equals the value of qubits.
        • Number of columns equals depth * 3.
      • If this check fails, it verifies if an activation matrix has 3 pages. If so, it outputs Error Code: 1030 - Activation matrix conversion unsuccessful.
      • train.json
  • convert_matrices

    This method converts the activation matrices as follows:

    • Each matrix consists of 3 pages.

    • They contain as many rows as the number of qubits and as many columns as the circuit depth (depth).

    • Intermediate check:

      • Before starting the conversion, verify the following properties in the matrices:

        • Each activation matrix has 3 pages.
        • Each activation matrix has a name.
        • Each activation matrix has dimensions:
          • Rows = qubits
          • Columns = depth

        If any of these checks fail, return Error Code: 1031 - Activation matrix invalid before conversion.

    Conversion Process:

    • For each cell in the matrices, the values from the 3 pages are combined. For example:
      • Page 1, Row 1, Column 1: Value A
      • Page 2, Row 1, Column 1: Value B
      • Page 3, Row 1, Column 1: Value C
      • → The final matrix for Row 1, Column 1 contains a page with values: Position 1 = A, Position 2 = B, Position 3 = C
    • After conversion, the resulting matrices are stored in activation_matrices.
    • Finally, each matrix is checked to ensure it has a name, and its dimensions are validated using the method check_final_matrix.
    Error Code: 1008 - Activation matrix does not meet required dimensions.
    
  • check_final_matrix

    This method checks if a given matrix meets the following conditions:

    • It has as many rows as the number of qubits.
    • It has as many columns as three times the depth value.

    This check is performed for each individual matrix to ensure the dimensions are correct.

  • create_training_matrix

    This method creates a training matrix based on the existing values:

    • The training matrix has as many rows as the number of qubits and as many columns as three times the depth value.
    • Values are randomly generated and range between -2π and 2π.
    • After creation, the matrix is validated using check_final_matrix to ensure the dimensions meet the requirements.
    • If the dimensions do not match:
    Error Code: 1007 - Training matrix does not meet required dimensions.
    

    The matrix is then saved in train.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants