-
Notifications
You must be signed in to change notification settings - Fork 5
Data
Leon edited this page Nov 10, 2024
·
1 revision
Project: LILY-QML
Version: 2.0.0 LLY-DML
Author: Leon Kaiser
Contact: info@lilyqml.de
Website: www.lilyqml.de
Contributors: Claudia Zendejas-Morales (@clausia)
The Data
class is designed to manage quantum circuit activation matrices within the LILY-QML project. It handles loading and converting data necessary for quantum computations, ensuring that matrices meet required dimensions and formats.
-
Purpose: Initializes the
Data
class by setting up the number of qubits, the circuit depth, activation matrices, and the working directory. -
Parameters:
-
qubits
(int): The number of qubits, corresponding to the number of rows in the matrices. -
depth
(int): The depth of the circuit, corresponding to the number of columns in the matrices. -
activation_matrices
(list, optional): Contains the three-dimensional activation matrices. Defaults to an empty list if not provided. -
working_directory
(str): The directory where data files and logs are managed. Defaults to'var'
.
-
-
Key Attributes:
self.qubits
self.depth
self.activation_matrices
self.working_directory
- Returns: None.
-
Purpose: Loads values for qubits, depth, and activation matrices from
data.json
. -
Operations:
- Opens
data.json
in the working directory. - Loads
qubits
,depth
, andactivation_matrices
from the file. - Converts activation matrices data into NumPy arrays.
- Opens
-
Returns:
-
None
if successful. - Error code
"Error Code: 1028 - data.json not found"
ifdata.json
is missing. - Error code
"Error Code: 1029 - train.json not found"
iftrain.json
is missing.
-
- Purpose: Returns the stored activation matrices, ensuring that they have correct properties.
-
Operations:
- Checks each matrix for the presence of the
'name'
key. - Validates the shape of each matrix's data to ensure it matches the required dimensions (
qubits x depth * 3 x 3
).
- Checks each matrix for the presence of the
-
Returns:
- List of activation matrices if valid.
- Error code
"Error Code: 1030 - Activation matrix conversion unsuccessful"
if validation fails.
- Purpose: Converts activation matrices to a specific format by combining values from 3 pages.
-
Operations:
- Validates initial properties of each matrix before conversion.
- Ensures each matrix has a
'name'
key. - Checks that each matrix's data has 3 pages (third dimension).
- Validates that the shape of each matrix matches
(qubits, depth, 3)
.
- Ensures each matrix has a
- Conversion process:
- Creates a new matrix with dimensions
qubits x (depth * 3)
. - Flattens the values from the 3 pages into the new matrix.
- Creates a new matrix with dimensions
- Validates the final matrices after conversion using
check_final_matrix
.
- Validates initial properties of each matrix before conversion.
-
Returns:
-
None
if successful. - Error code
"Error Code: 1031 - Activation matrix invalid before conversion"
if initial checks fail. - Error code
"Error Code: 1008 - Activation matrix does not meet required dimensions"
if final validation fails.
-
- Purpose: Checks if a matrix meets the final required dimensions.
-
Parameters:
-
matrix
(ndarray): The matrix to check.
-
-
Operations:
- Verifies that the matrix has dimensions
qubits x (depth * 3)
.
- Verifies that the matrix has dimensions
-
Returns:
-
True
if valid. -
False
otherwise.
-
-
Purpose: Creates a training matrix with randomized values between
-2π
and2π
. -
Operations:
- Generates a random matrix of shape
(qubits, depth * 3)
with values in the specified range. - Validates the dimensions of the training matrix.
- Checks if the shape matches
(qubits, depth * 3)
. - Uses
check_final_matrix
for additional validation.
- Checks if the shape matches
- Saves the training matrix to
'train.json'
in the working directory.
- Generates a random matrix of shape
-
Returns:
-
None
if successful. - Error code
"Error Code: 1007 - Training matrix does not meet required dimensions"
if validation fails.
-
This class is essential for preparing and validating the data required for quantum computations in the LILY-QML project. It ensures that activation matrices and training matrices are correctly formatted and meet the necessary dimensional requirements for subsequent processing.