-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Class: All
Method: optimize
In this method, various classes and methods are executed to orchestrate the optimization process of the training matrix.
Overview
The optimization process involves iterating through all optimizers and activation matrices specified in data.json. For each combination, a training loop is executed multiple times to refine the training matrix. Finally, a cross-training phase is conducted to reinforce the phases across all scenarios.
Process Details
1. Optimizer Loop
This loop iterates through all optimizers stored in data.json.
- For Each Optimizer:
- Proceed to the Activation Matrices Loop.
2. Activation Matrices Loop
In this loop, we iterate through all activation matrices.
- For Each Activation Matrix:
-
Evaluate Activation Matrix State:
- Execute the
get_statemethod to evaluate the state of the current activation matrix.
- Execute the
-
Initialize Optimizer:
- Call the
startmethod of theOptimizerclass with the target state and the current optimizer.
- Call the
-
Training Loop (Iteration Loop):
This loop runs for a number of iterations specified by the
Iterationvalue, which defines how many times we iterate with an activation matrix.- For Each Iteration:
- Circuit Creation:
- Insert the activation matrix and the training matrix into a circuit.
- Measurement:
- Measure the circuit to obtain measurement values.
- Optimization:
- Pass the measurement values to the optimizer.
- Execute the
optimizemethod of theOptimizerclass. - With the newly generated matrix from the optimizer:
- Regenerate the circuit.
- Measure it again.
- Pass the new measurements back to the optimizer.
- Circuit Creation:
- For Each Iteration:
-
Cross-Training Phase:
- At the very end, execute the
crosstraining(Optimizer)method to reinforce the phases for all scenarios.
- At the very end, execute the
-
Documentation and Logging
Rules for the Training Matrices
- Saving Training Matrices:
- Every state at the end of the training loop is saved in
train.json.- Each matrix returned at the end of the loop is written into
train.json.
- Each matrix returned at the end of the loop is written into
- Every state at the end of the training loop is saved in
- Initial Training Matrix:
- The initial matrix in
train.jsonis never manipulated.- Every optimizer starts with this initial matrix.
- In
train.json, each optimizer gets a matrix under theinitial_matrixkey, which is the starting matrix fromdata.json. - All permutations through the optimizer in the iteration loop are stored as separate matrices in the optimizer's section, along with the iteration number.
- The initial matrix in
- Final Training Matrix:
- The last training matrix is saved under
final_ombc(Final Optimized Matrix Before Cross-Training).
- The last training matrix is saved under
Logging Rules
- Logging Optimizer Usage:
- Log every time a new optimizer is used.
- Logging Activation Matrix Completion:
- Log every time an activation matrix has been completed.
- Include how many entries were made in
train.jsonper activation matrix.
- Include how many entries were made in
- Log every time an activation matrix has been completed.
Additional Notes
- Target States:
- Target states are saved in
train.jsonunder:- The respective optimizer section.
- The respective activation matrix section.
- Stored as
target_state.
- Target states are saved in