In [1]:
Copied!
!pip install -r requirements.txt
!pip install -r requirements.txt
Requirement already satisfied: pandas==1.1.5 in /opt/conda/envs/qc_hcls_retrosynthetic_planning_qrl/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (1.1.5) Requirement already satisfied: rdkit==2023.3.1 in /opt/conda/envs/qc_hcls_retrosynthetic_planning_qrl/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (2023.3.1) Requirement already satisfied: tqdm==4.65.0 in /opt/conda/envs/qc_hcls_retrosynthetic_planning_qrl/lib/python3.9/site-packages (from -r requirements.txt (line 3)) (4.65.0) Requirement already satisfied: python-dateutil>=2.7.3 in /opt/conda/envs/qc_hcls_retrosynthetic_planning_qrl/lib/python3.9/site-packages (from pandas==1.1.5->-r requirements.txt (line 1)) (2.8.2) Requirement already satisfied: pytz>=2017.2 in /opt/conda/envs/qc_hcls_retrosynthetic_planning_qrl/lib/python3.9/site-packages (from pandas==1.1.5->-r requirements.txt (line 1)) (2023.3) Requirement already satisfied: numpy>=1.15.4 in /opt/conda/envs/qc_hcls_retrosynthetic_planning_qrl/lib/python3.9/site-packages (from pandas==1.1.5->-r requirements.txt (line 1)) (1.23.5) Requirement already satisfied: Pillow in /opt/conda/envs/qc_hcls_retrosynthetic_planning_qrl/lib/python3.9/site-packages (from rdkit==2023.3.1->-r requirements.txt (line 2)) (9.5.0) Requirement already satisfied: six>=1.5 in /opt/conda/envs/qc_hcls_retrosynthetic_planning_qrl/lib/python3.9/site-packages (from python-dateutil>=2.7.3->pandas==1.1.5->-r requirements.txt (line 1)) (1.16.0)
Algorithm Explained¶
In [2]:
Copied!
from hybridjobs.utility.RetroGateModel import RetroRLModel
from hybridjobs.utility.RetroRLAgent import RetroRLAgent
from hybridjobs.utility.DataPrepare import Prepare
from hybridjobs.utility.BruteForceSearch import expansion, Product, Reaction
import time
import numpy as np
# # Use Braket SDK Cost Tracking to estimate the cost to run this example
# from braket.tracking import Tracker
# t = Tracker().start()
timestamp = time.strftime("%Y%m%d-%H")
from hybridjobs.utility.RetroGateModel import RetroRLModel
from hybridjobs.utility.RetroRLAgent import RetroRLAgent
from hybridjobs.utility.DataPrepare import Prepare
from hybridjobs.utility.BruteForceSearch import expansion, Product, Reaction
import time
import numpy as np
# # Use Braket SDK Cost Tracking to estimate the cost to run this example
# from braket.tracking import Tracker
# t = Tracker().start()
timestamp = time.strftime("%Y%m%d-%H")
In [3]:
Copied!
# config your aws account in your ~/.aws/config
import os
os.environ['AWS_DEFAULT_REGION']='us-west-1'
# config your aws account in your ~/.aws/config
import os
os.environ['AWS_DEFAULT_REGION']='us-west-1'
In [4]:
Copied!
data_path = 'data'
# download dateset
!mkdir $data_path
!mkdir $data_path\smiles
!wget https://d1o8djwwk7diqy.cloudfront.net/retrosynthetic-plannin-dataset.zip
!unzip -o retrosynthetic-plannin-dataset.zip
# # windows
# !copy retrosynthetic-planning-dataset $data_path
# !copy data\smiles_map.npy data\smiles\smiles_map.npy
# linux
!cp -r retrosynthetic-planning-dataset/* $data_path
!cp data/smiles_map.npy data/smiles
!rm retrosynthetic-plannin-dataset.zip
data_path = 'data'
# download dateset
!mkdir $data_path
!mkdir $data_path\smiles
!wget https://d1o8djwwk7diqy.cloudfront.net/retrosynthetic-plannin-dataset.zip
!unzip -o retrosynthetic-plannin-dataset.zip
# # windows
# !copy retrosynthetic-planning-dataset $data_path
# !copy data\smiles_map.npy data\smiles\smiles_map.npy
# linux
!cp -r retrosynthetic-planning-dataset/* $data_path
!cp data/smiles_map.npy data/smiles
!rm retrosynthetic-plannin-dataset.zip
mkdir: cannot create directory ‘data’: File exists mkdir: cannot create directory ‘datasmiles’: File exists --2023-06-07 11:13:27-- https://d1o8djwwk7diqy.cloudfront.net/retrosynthetic-plannin-dataset.zip Resolving d1o8djwwk7diqy.cloudfront.net (d1o8djwwk7diqy.cloudfront.net)... 13.32.192.18, 13.32.192.111, 13.32.192.102, ... Connecting to d1o8djwwk7diqy.cloudfront.net (d1o8djwwk7diqy.cloudfront.net)|13.32.192.18|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 3841896 (3.7M) [application/zip] Saving to: ‘retrosynthetic-plannin-dataset.zip’ retrosynthetic-plan 100%[===================>] 3.66M --.-KB/s in 0.06s 2023-06-07 11:13:28 (63.3 MB/s) - ‘retrosynthetic-plannin-dataset.zip’ saved [3841896/3841896] Archive: retrosynthetic-plannin-dataset.zip inflating: retrosynthetic-planning-dataset/buyable.npy inflating: retrosynthetic-planning-dataset/target_product.npy inflating: retrosynthetic-planning-dataset/reactions_dictionary.npy inflating: retrosynthetic-planning-dataset/smiles_map.npy inflating: retrosynthetic-planning-dataset/ground_truth.npy inflating: retrosynthetic-planning-dataset/Deadend.npy inflating: retrosynthetic-planning-dataset/uspto50k.xlsx inflating: retrosynthetic-planning-dataset/smiles_dictionary.npy
In [5]:
Copied!
# input: predata_uspto-50k.xlsx
# output: file1.npy,file2.npy
raw_path = 'data/uspto50k.xlsx'
prepare = Prepare(raw_path)
prepare.generate_files() #
prepare.generate_ground_truth()
ground_truth = np.load(prepare.path+'ground_truth.npy', allow_pickle=True).tolist()
# input: predata_uspto-50k.xlsx
# output: file1.npy,file2.npy
raw_path = 'data/uspto50k.xlsx'
prepare = Prepare(raw_path)
prepare.generate_files() #
prepare.generate_ground_truth()
ground_truth = np.load(prepare.path+'ground_truth.npy', allow_pickle=True).tolist()
INFO:root:Files are present. INFO:root:All files are generated! INFO:root:File is present.
Step 2: Build Model¶
In this part, we build the circuit model for retrosynthetic planning
In [6]:
Copied!
# initial the RetroRLModel object
init_param = {}
method = ['retro-rl', 'retro-qrl']
for mt in method:
if mt == 'retro-rl':
init_param[mt] = {}
init_param[mt]['param'] = ['inputsize', 'middlesize', 'outputsize']
elif mt == 'retro-qrl':
init_param[mt] = {}
init_param[mt]['param'] = ['n_qubits', 'device', 'framework', 'shots', 'layers']
retro_rl_model = RetroRLModel(data=None, method=method, **init_param)
# initial the RetroRLModel object
init_param = {}
method = ['retro-rl', 'retro-qrl']
for mt in method:
if mt == 'retro-rl':
init_param[mt] = {}
init_param[mt]['param'] = ['inputsize', 'middlesize', 'outputsize']
elif mt == 'retro-qrl':
init_param[mt] = {}
init_param[mt]['param'] = ['n_qubits', 'device', 'framework', 'shots', 'layers']
retro_rl_model = RetroRLModel(data=None, method=method, **init_param)
INFO:root:initial reinforcement learning for retrosynthetic-planning INFO:root:initial quantum reinforcement learning for retrosynthetic-planning
In [7]:
Copied!
model_param={}
method = 'retro-rl'
model_param[method] = {}
model_param[method]['inputsize'] = [256]
model_param[method]['middlesize'] = [256,512,1024]
model_param[method]['outputsize'] = [1]
retro_rl_model.build_model(**model_param)
model_param={}
method = 'retro-rl'
model_param[method] = {}
model_param[method]['inputsize'] = [256]
model_param[method]['middlesize'] = [256,512,1024]
model_param[method]['outputsize'] = [1]
retro_rl_model.build_model(**model_param)
INFO:root:Construct model for inputsize:256,middlesize:256,outputsize:1 0.00031487147013346356 min INFO:root:Construct model for inputsize:256,middlesize:512,outputsize:1 1.551707585652669e-05 min INFO:root:Construct model for inputsize:256,middlesize:1024,outputsize:1 3.147522608439128e-05 min
In [8]:
Copied!
model_param={}
method = 'retro-qrl'
model_param[method] = {}
model_param[method]['n_qubits'] = [8]
model_param[method]['device'] = ['local', 'sv1', 'aspen-m2']
model_param[method]['framework'] = ['pennylane']
model_param[method]['shots'] = [100,1000]
model_param[method]['layers'] = [1,2,3]
retro_rl_model.build_model(**model_param)
model_param={}
method = 'retro-qrl'
model_param[method] = {}
model_param[method]['n_qubits'] = [8]
model_param[method]['device'] = ['local', 'sv1', 'aspen-m2']
model_param[method]['framework'] = ['pennylane']
model_param[method]['shots'] = [100,1000]
model_param[method]['layers'] = [1,2,3]
retro_rl_model.build_model(**model_param)
INFO:root:Construct model for n_qubits:8,device:local,framework:pennylane,layers:1 1.0808308919270834e-05 min INFO:root:Construct model for n_qubits:8,device:local,framework:pennylane,layers:2 4.295508066813151e-06 min INFO:root:Construct model for n_qubits:8,device:local,framework:pennylane,layers:3 2.0464261372884116e-06 min INFO:root:Construct model for n_qubits:8,device:local,framework:pennylane,layers:1 7.522106170654297e-06 min INFO:root:Construct model for n_qubits:8,device:local,framework:pennylane,layers:2 2.475579579671224e-06 min INFO:root:Construct model for n_qubits:8,device:local,framework:pennylane,layers:3 7.383028666178385e-06 min INFO:root:Construct model for n_qubits:8,device:sv1,framework:pennylane,layers:1 1.915295918782552e-06 min INFO:root:Construct model for n_qubits:8,device:sv1,framework:pennylane,layers:2 2.7259190877278646e-06 min INFO:root:Construct model for n_qubits:8,device:sv1,framework:pennylane,layers:3 2.2530555725097655e-06 min INFO:root:Construct model for n_qubits:8,device:sv1,framework:pennylane,layers:1 9.270509084065755e-06 min INFO:root:Construct model for n_qubits:8,device:sv1,framework:pennylane,layers:2 7.541974385579427e-06 min INFO:root:Construct model for n_qubits:8,device:sv1,framework:pennylane,layers:3 2.276897430419922e-06 min INFO:root:Construct model for n_qubits:8,device:aspen-m2,framework:pennylane,layers:1 1.2795130411783853e-06 min INFO:root:Construct model for n_qubits:8,device:aspen-m2,framework:pennylane,layers:2 2.2252400716145835e-06 min INFO:root:Construct model for n_qubits:8,device:aspen-m2,framework:pennylane,layers:3 1.33514404296875e-06 min INFO:root:Construct model for n_qubits:8,device:aspen-m2,framework:pennylane,layers:1 2.1537144978841146e-06 min INFO:root:Construct model for n_qubits:8,device:aspen-m2,framework:pennylane,layers:2 1.4901161193847656e-06 min INFO:root:Construct model for n_qubits:8,device:aspen-m2,framework:pennylane,layers:3 2.3722648620605467e-06 min
We can use the following method to check the properties of model. This way, we can build many models conveniently. After that, we save the model and update the value of model_path.
In [9]:
Copied!
# describe the model parameters
model_info = retro_rl_model.describe_model()
# describe the model parameters
model_info = retro_rl_model.describe_model()
INFO:root:method: retro-rl INFO:root:param: inputsize, value {256} INFO:root:param: middlesize, value {256, 512, 1024} INFO:root:param: outputsize, value {1} INFO:root:method: retro-qrl INFO:root:param: n_qubits, value {8} INFO:root:param: device, value {'sv1', 'aspen-m2', 'local'} INFO:root:param: framework, value {'pennylane'} INFO:root:param: shots, value {1000, 100} INFO:root:param: layers, value {1, 2, 3}
In [10]:
Copied!
# save the model
model_path = retro_rl_model.save("latest")
print(f"You have built the nn model for RL and saved it as {model_path}")
# save the model
model_path = retro_rl_model.save("latest")
print(f"You have built the nn model for RL and saved it as {model_path}")
INFO:root:finish save retrorl_model_latest.pickle
You have built the nn model for RL and saved it as ./retrorl_model_latest.pickle
In [11]:
Copied!
# !cp $model_path $data_path
# windows
!cp $model_path $data_path
# !cp $model_path $data_path
# windows
!cp $model_path $data_path
Step 3: Learn Retrosynthetic Planning¶
In this part, we use cpu to run classical model for retrosynthetic planning and simulators/NISQ devices to run quantum model for retrosysnthetic planning.
In [12]:
Copied!
model_path='./retrorl_model_latest.pickle'
# get the model you want to optimize
n_qubits = 8
device = 'local'
framework = 'pennylane'
shots = 100
model_name = "{}_{}_{}_{}".format(n_qubits, device, framework, shots)
method = "retro-qrl"
model_path='./retrorl_model_latest.pickle'
# get the model you want to optimize
n_qubits = 8
device = 'local'
framework = 'pennylane'
shots = 100
model_name = "{}_{}_{}_{}".format(n_qubits, device, framework, shots)
method = "retro-qrl"
In [13]:
Copied!
# train_mode can be: "local-instance", "local-job", "hybrid-job"
train_mode = "hybrid-job"
# train_mode can be: "local-instance", "local-job", "hybrid-job"
train_mode = "hybrid-job"
In [16]:
Copied!
data_path = 'data'
agent_param = {}
agent_param["data_path"] = data_path
agent_param["train_mode"] = train_mode
agent_param["model_name"] = model_name
agent_param["model_path"] = model_path
retro_model = None
if train_mode == "local-instance":
# get model
retro_rl_model = RetroRLModel.load(model_path)
model_info = retro_rl_model.describe_model()
retro_model = retro_rl_model.get_model(method, model_name)
retro_rl_agent = RetroRLAgent(retro_model, method, **agent_param)
retro_rl_agent.game_job()
job_arn = retro_rl_agent.get_job_arn()
print(f"create job with arn {job_arn}")
data_path = 'data'
agent_param = {}
agent_param["data_path"] = data_path
agent_param["train_mode"] = train_mode
agent_param["model_name"] = model_name
agent_param["model_path"] = model_path
retro_model = None
if train_mode == "local-instance":
# get model
retro_rl_model = RetroRLModel.load(model_path)
model_info = retro_rl_model.describe_model()
retro_model = retro_rl_model.get_model(method, model_name)
retro_rl_agent = RetroRLAgent(retro_model, method, **agent_param)
retro_rl_agent.game_job()
job_arn = retro_rl_agent.get_job_arn()
print(f"create job with arn {job_arn}")
INFO:root:load data... INFO:root:model is None INFO:botocore.credentials:Found credentials in shared credentials file: ~/.aws/credentials INFO:botocore.credentials:Found credentials in shared credentials file: ~/.aws/credentials
Going to run local mode create job with arn arn:aws:braket:us-west-1:002224604296:job/retrorl-job-local-torch-1686136442
In [15]:
Copied!
# retro_rl_agent.get_job().cancel()
# retro_rl_agent.get_job().cancel()
Out[15]:
'CANCELLING'
In [17]:
Copied!
model_path='./retrorl_model_latest.pickle'
# get the model you want to optimize
inputsize = 256
middlesize = 512
outputsize = 1
model_name = "{}_{}_{}".format(inputsize, middlesize, outputsize)
method = "retro-rl"
# train_mode can be: "local-instance", "local-job", "hybrid-job"
train_mode = "hybrid-job"
model_path='./retrorl_model_latest.pickle'
# get the model you want to optimize
inputsize = 256
middlesize = 512
outputsize = 1
model_name = "{}_{}_{}".format(inputsize, middlesize, outputsize)
method = "retro-rl"
# train_mode can be: "local-instance", "local-job", "hybrid-job"
train_mode = "hybrid-job"
In [18]:
Copied!
data_path = 'data'
agent_param = {}
agent_param["data_path"] = data_path
agent_param["train_mode"] = train_mode
agent_param["model_name"] = model_name
agent_param["model_path"] = model_path
retro_rl_model = RetroRLModel.load(model_path)
model_info = retro_rl_model.describe_model()
retro_model = retro_rl_model.get_model(method, model_name)
retro_rl_agent = RetroRLAgent(retro_model, method, **agent_param)
retro_rl_agent.game()
retro_rl_agent.save("latest", path='data')
data_path = 'data'
agent_param = {}
agent_param["data_path"] = data_path
agent_param["train_mode"] = train_mode
agent_param["model_name"] = model_name
agent_param["model_path"] = model_path
retro_rl_model = RetroRLModel.load(model_path)
model_info = retro_rl_model.describe_model()
retro_model = retro_rl_model.get_model(method, model_name)
retro_rl_agent = RetroRLAgent(retro_model, method, **agent_param)
retro_rl_agent.game()
retro_rl_agent.save("latest", path='data')
INFO:root:method: retro-rl INFO:root:param: inputsize, value {256} INFO:root:param: middlesize, value {256, 512, 1024} INFO:root:param: outputsize, value {1} INFO:root:method: retro-qrl INFO:root:param: n_qubits, value {8} INFO:root:param: device, value {'sv1', 'aspen-m2', 'local'} INFO:root:param: framework, value {'pennylane'} INFO:root:param: shots, value {1000, 100} INFO:root:param: layers, value {1, 2, 3} INFO:root:load data... INFO:root:model is {'model_name': '256_512_1', 'version': '1686136414', 'nn_model': Model( (relu): ReLU() (value_fc1): Linear(in_features=256, out_features=512, bias=True) (value_fc2): Linear(in_features=512, out_features=1, bias=True) )}
episode 1 episode 2 episode 3 episode 4 episode 5 episode 6 episode 7 episode 8 episode 9 episode 10 episode 11 episode 12 episode 13 episode 14 episode 15 episode 16 episode 17 episode 18 episode 19 episode 20 episode 21 episode 22 episode 23 episode 24 episode 25 episode 26 episode 27 episode 28 episode 29 episode 30 epsiode 30 training... finish epoch 0 for 0.0037224968274434406 minutes finish epoch 1 for 3.91999880472819e-05 minutes finish epoch 2 for 1.6176700592041014e-05 minutes finish epoch 3 for 1.619259516398112e-05 minutes finish epoch 4 for 1.476605733235677e-05 minutes finish epoch 5 for 1.403490702311198e-05 minutes finish epoch 6 for 1.4869372049967448e-05 minutes finish epoch 7 for 1.5866756439208984e-05 minutes finish epoch 8 for 1.4122327168782552e-05 minutes finish epoch 9 for 1.409451166788737e-05 minutes finish epoch 10 for 1.4599164326985677e-05 minutes finish epoch 11 for 1.5020370483398438e-05 minutes finish epoch 12 for 1.4833609263102214e-05 minutes finish epoch 13 for 1.4098485310872396e-05 minutes finish epoch 14 for 1.3717015584309895e-05 minutes finish epoch 15 for 1.5306472778320313e-05 minutes finish epoch 16 for 1.4853477478027343e-05 minutes finish epoch 17 for 1.4038880666097005e-05 minutes finish epoch 18 for 1.375277837117513e-05 minutes finish epoch 19 for 1.4321009318033855e-05 minutes finish epoch 20 for 1.4003117879231771e-05 minutes finish epoch 21 for 1.4710426330566407e-05 minutes finish epoch 22 for 1.4030933380126953e-05 minutes finish epoch 23 for 1.362164815266927e-05 minutes finish epoch 24 for 1.398324966430664e-05 minutes finish epoch 25 for 1.4173984527587891e-05 minutes finish epoch 26 for 1.4197826385498046e-05 minutes finish epoch 27 for 1.3323624928792318e-05 minutes finish epoch 28 for 1.3899803161621093e-05 minutes finish epoch 29 for 1.4718373616536459e-05 minutes finish epoch 30 for 1.4408429463704426e-05 minutes finish epoch 31 for 1.4126300811767578e-05 minutes finish epoch 32 for 1.3236204783121745e-05 minutes finish epoch 33 for 1.4026959737141928e-05 minutes finish epoch 34 for 1.4611085255940755e-05 minutes finish epoch 35 for 1.5461444854736327e-05 minutes finish epoch 36 for 1.5115737915039062e-05 minutes finish epoch 37 for 1.3645490010579427e-05 minutes finish epoch 38 for 1.5616416931152344e-05 minutes finish epoch 39 for 1.548926035563151e-05 minutes finish epoch 40 for 1.4460086822509765e-05 minutes finish epoch 41 for 1.3911724090576172e-05 minutes finish epoch 42 for 1.3554096221923828e-05 minutes finish epoch 43 for 1.3935565948486329e-05 minutes finish epoch 44 for 1.4917055765787761e-05 minutes finish epoch 45 for 1.3748804728190104e-05 minutes finish epoch 46 for 1.371304194132487e-05 minutes finish epoch 47 for 1.3864040374755859e-05 minutes finish epoch 48 for 1.4579296112060547e-05 minutes finish epoch 49 for 1.4468034108479817e-05 minutes episode 31 episode 32 episode 33 episode 34 episode 35 episode 36 episode 37 episode 38 episode 39 episode 40 episode 41 episode 42 episode 43 episode 44 episode 45 episode 46 episode 47 episode 48 episode 49 episode 50 episode 51 episode 52 episode 53 episode 54 episode 55 episode 56 episode 57 episode 58 episode 59 episode 60 epsiode 60 training... finish epoch 0 for 2.126296361287435e-05 minutes finish epoch 1 for 1.627206802368164e-05 minutes finish epoch 2 for 1.451571782430013e-05 minutes finish epoch 3 for 1.3951460520426432e-05 minutes finish epoch 4 for 1.3756752014160157e-05 minutes finish epoch 5 for 1.3315677642822266e-05 minutes finish epoch 6 for 1.3911724090576172e-05 minutes finish epoch 7 for 1.4408429463704426e-05 minutes finish epoch 8 for 1.3617674509684245e-05 minutes finish epoch 9 for 1.3212362925211588e-05 minutes finish epoch 10 for 1.3327598571777343e-05 minutes finish epoch 11 for 1.4106432596842447e-05 minutes finish epoch 12 for 1.4503796895345053e-05 minutes finish epoch 13 for 1.360177993774414e-05 minutes finish epoch 14 for 1.3236204783121745e-05 minutes finish epoch 15 for 1.3693173726399739e-05 minutes finish epoch 16 for 1.3828277587890625e-05 minutes finish epoch 17 for 1.4225641886393229e-05 minutes finish epoch 18 for 1.3653437296549479e-05 minutes finish epoch 19 for 1.3482570648193359e-05 minutes finish epoch 20 for 1.531044642130534e-05 minutes finish epoch 21 for 1.4221668243408203e-05 minutes finish epoch 22 for 1.3641516367594401e-05 minutes finish epoch 23 for 1.3569990793863932e-05 minutes finish epoch 24 for 1.3212362925211588e-05 minutes finish epoch 25 for 1.3530254364013672e-05 minutes finish epoch 26 for 1.4277299245198568e-05 minutes finish epoch 27 for 1.3609727223714193e-05 minutes finish epoch 28 for 1.3510386149088541e-05 minutes finish epoch 29 for 1.3216336568196614e-05 minutes finish epoch 30 for 1.3625621795654297e-05 minutes finish epoch 31 for 1.4356772104899089e-05 minutes finish epoch 32 for 1.3724962870279949e-05 minutes finish epoch 33 for 1.3609727223714193e-05 minutes finish epoch 34 for 1.3168652852376302e-05 minutes finish epoch 35 for 1.3645490010579427e-05 minutes finish epoch 36 for 1.424551010131836e-05 minutes finish epoch 37 for 1.3327598571777343e-05 minutes finish epoch 38 for 1.329183578491211e-05 minutes finish epoch 39 for 1.5091896057128906e-05 minutes finish epoch 40 for 1.5485286712646485e-05 minutes finish epoch 41 for 1.3693173726399739e-05 minutes finish epoch 42 for 1.320044199625651e-05 minutes finish epoch 43 for 1.3295809427897135e-05 minutes finish epoch 44 for 1.430511474609375e-05 minutes finish epoch 45 for 1.4583269755045572e-05 minutes finish epoch 46 for 1.3613700866699219e-05 minutes finish epoch 47 for 1.3474623362223307e-05 minutes finish epoch 48 for 1.2969970703125e-05 minutes finish epoch 49 for 1.3788541158040365e-05 minutes episode 61 episode 62 episode 63 episode 64 episode 65 episode 66 episode 67 episode 68 episode 69 episode 70 episode 71 episode 72 episode 73 episode 74 episode 75 episode 76 episode 77 episode 78 episode 79 episode 80 episode 81 episode 82 episode 83 episode 84 episode 85 episode 86 episode 87 episode 88 episode 89 episode 90 epsiode 90 training... finish epoch 0 for 2.1819273630777995e-05 minutes finish epoch 1 for 1.48773193359375e-05 minutes finish epoch 2 for 1.3764699300130209e-05 minutes finish epoch 3 for 1.373291015625e-05 minutes finish epoch 4 for 1.41143798828125e-05 minutes finish epoch 5 for 1.3422966003417968e-05 minutes finish epoch 6 for 1.3260046641031901e-05 minutes finish epoch 7 for 1.3438860575358073e-05 minutes finish epoch 8 for 1.4507770538330078e-05 minutes finish epoch 9 for 1.3649463653564453e-05 minutes finish epoch 10 for 1.354217529296875e-05 minutes finish epoch 11 for 1.3271967569986979e-05 minutes finish epoch 12 for 1.3593832651774088e-05 minutes finish epoch 13 for 1.3848145802815756e-05 minutes finish epoch 14 for 1.3609727223714193e-05 minutes finish epoch 15 for 1.3418992360432942e-05 minutes finish epoch 16 for 1.320044199625651e-05 minutes finish epoch 17 for 1.3645490010579427e-05 minutes finish epoch 18 for 1.3856093088785807e-05 minutes finish epoch 19 for 1.3415018717447916e-05 minutes finish epoch 20 for 1.3287862141927084e-05 minutes finish epoch 21 for 1.310110092163086e-05 minutes finish epoch 22 for 1.371304194132487e-05 minutes finish epoch 23 for 1.4022986094156902e-05 minutes finish epoch 24 for 1.3379255930582682e-05 minutes finish epoch 25 for 1.3442834218343099e-05 minutes finish epoch 26 for 1.3212362925211588e-05 minutes finish epoch 27 for 1.3482570648193359e-05 minutes finish epoch 28 for 1.3649463653564453e-05 minutes finish epoch 29 for 1.333157221476237e-05 minutes finish epoch 30 for 1.333157221476237e-05 minutes finish epoch 31 for 1.3498465220133464e-05 minutes finish epoch 32 for 1.3426939646402996e-05 minutes finish epoch 33 for 1.392364501953125e-05 minutes finish epoch 34 for 1.3339519500732423e-05 minutes finish epoch 35 for 1.3434886932373047e-05 minutes finish epoch 36 for 1.3971328735351563e-05 minutes finish epoch 37 for 1.3367335001627605e-05 minutes finish epoch 38 for 1.3959407806396484e-05 minutes finish epoch 39 for 1.33514404296875e-05 minutes finish epoch 40 for 1.3323624928792318e-05 minutes finish epoch 41 for 1.3927618662516275e-05 minutes finish epoch 42 for 1.3434886932373047e-05 minutes finish epoch 43 for 1.3335545857747395e-05 minutes finish epoch 44 for 1.3188521067301433e-05 minutes finish epoch 45 for 1.3057390848795573e-05 minutes finish epoch 46 for 1.3530254364013672e-05 minutes finish epoch 47 for 1.3748804728190104e-05 minutes finish epoch 48 for 1.339117685953776e-05 minutes finish epoch 49 for 1.3264020284016927e-05 minutes episode 91 episode 92 episode 93 episode 94 episode 95 episode 96 episode 97 episode 98 episode 99 episode 100 episode 101 episode 102 episode 103 episode 104 episode 105 episode 106 episode 107 episode 108 episode 109 episode 110 episode 111 episode 112 episode 113 episode 114 episode 115 episode 116 episode 117 episode 118 episode 119 episode 120 epsiode 120 training... finish epoch 0 for 2.7883052825927735e-05 minutes finish epoch 1 for 1.6164779663085937e-05 minutes finish epoch 2 for 1.537005106608073e-05 minutes finish epoch 3 for 1.559257507324219e-05 minutes finish epoch 4 for 1.462697982788086e-05 minutes finish epoch 5 for 1.4197826385498046e-05 minutes finish epoch 6 for 1.4150142669677735e-05 minutes finish epoch 7 for 1.3852119445800782e-05 minutes finish epoch 8 for 1.3736883799235026e-05 minutes finish epoch 9 for 1.432498296101888e-05 minutes finish epoch 10 for 1.3919671376546224e-05 minutes finish epoch 11 for 1.3963381449381511e-05 minutes finish epoch 12 for 1.3971328735351563e-05 minutes finish epoch 13 for 1.434485117594401e-05 minutes finish epoch 14 for 1.3760725657145183e-05 minutes finish epoch 15 for 1.3641516367594401e-05 minutes finish epoch 16 for 1.3887882232666016e-05 minutes finish epoch 17 for 1.4853477478027343e-05 minutes finish epoch 18 for 1.5270709991455077e-05 minutes finish epoch 19 for 1.3891855875651041e-05 minutes finish epoch 20 for 1.4321009318033855e-05 minutes finish epoch 21 for 1.4146169026692709e-05 minutes finish epoch 22 for 1.3899803161621093e-05 minutes finish epoch 23 for 1.470645268758138e-05 minutes finish epoch 24 for 1.4110406239827473e-05 minutes finish epoch 25 for 1.3971328735351563e-05 minutes finish epoch 26 for 1.3907750447591146e-05 minutes finish epoch 27 for 1.4424324035644531e-05 minutes finish epoch 28 for 1.3756752014160157e-05 minutes finish epoch 29 for 1.3748804728190104e-05 minutes finish epoch 30 for 1.4750162760416667e-05 minutes finish epoch 31 for 1.4253457387288411e-05 minutes finish epoch 32 for 1.4452139536539714e-05 minutes finish epoch 33 for 1.3840198516845702e-05 minutes finish epoch 34 for 1.3573964436848958e-05 minutes finish epoch 35 for 1.4058748881022136e-05 minutes finish epoch 36 for 1.3808409372965494e-05 minutes finish epoch 37 for 1.4487902323404948e-05 minutes finish epoch 38 for 1.377264658610026e-05 minutes finish epoch 39 for 1.3458728790283204e-05 minutes finish epoch 40 for 1.4011065165201823e-05 minutes finish epoch 41 for 1.3987223307291666e-05 minutes finish epoch 42 for 1.3800462086995443e-05 minutes finish epoch 43 for 1.381238301595052e-05 minutes finish epoch 44 for 1.3967355092366537e-05 minutes finish epoch 45 for 1.3454755147298176e-05 minutes finish epoch 46 for 1.436471939086914e-05 minutes finish epoch 47 for 1.381238301595052e-05 minutes finish epoch 48 for 1.373291015625e-05 minutes finish epoch 49 for 1.4233589172363282e-05 minutes episode 121 episode 122 episode 123 episode 124 episode 125 episode 126 episode 127 episode 128 episode 129 episode 130 episode 131 episode 132 episode 133 episode 134 episode 135 episode 136 episode 137 episode 138 episode 139 episode 140 episode 141 episode 142 episode 143 episode 144 episode 145 episode 146 episode 147 episode 148 episode 149 episode 150 epsiode 150 training... finish epoch 0 for 2.6440620422363283e-05 minutes finish epoch 1 for 1.4535586039225261e-05 minutes finish epoch 2 for 1.3935565948486329e-05 minutes finish epoch 3 for 1.4289220174153645e-05 minutes finish epoch 4 for 1.591046651204427e-05 minutes finish epoch 5 for 1.4082590738932292e-05 minutes finish epoch 6 for 1.366138458251953e-05 minutes finish epoch 7 for 1.3788541158040365e-05 minutes finish epoch 8 for 1.4400482177734375e-05 minutes finish epoch 9 for 1.4567375183105469e-05 minutes finish epoch 10 for 1.394351323445638e-05 minutes finish epoch 11 for 1.3899803161621093e-05 minutes finish epoch 12 for 1.394351323445638e-05 minutes finish epoch 13 for 1.3697147369384766e-05 minutes finish epoch 14 for 1.4297167460123698e-05 minutes finish epoch 15 for 1.3470649719238281e-05 minutes finish epoch 16 for 1.354217529296875e-05 minutes finish epoch 17 for 1.4046827952067057e-05 minutes finish epoch 18 for 1.4313062032063802e-05 minutes finish epoch 19 for 1.3740857442220052e-05 minutes finish epoch 20 for 1.3792514801025391e-05 minutes finish epoch 21 for 1.3438860575358073e-05 minutes finish epoch 22 for 1.4003117879231771e-05 minutes finish epoch 23 for 1.4241536458333334e-05 minutes finish epoch 24 for 1.3768672943115234e-05 minutes finish epoch 25 for 1.3756752014160157e-05 minutes finish epoch 26 for 1.3224283854166667e-05 minutes finish epoch 27 for 1.4082590738932292e-05 minutes finish epoch 28 for 1.4396508534749349e-05 minutes finish epoch 29 for 1.38243039449056e-05 minutes finish epoch 30 for 1.3808409372965494e-05 minutes finish epoch 31 for 1.3939539591471355e-05 minutes finish epoch 32 for 1.3653437296549479e-05 minutes finish epoch 33 for 1.4309088389078776e-05 minutes finish epoch 34 for 1.3407071431477865e-05 minutes finish epoch 35 for 1.3474623362223307e-05 minutes finish epoch 36 for 1.4150142669677735e-05 minutes finish epoch 37 for 1.4122327168782552e-05 minutes finish epoch 38 for 1.3931592305501301e-05 minutes finish epoch 39 for 1.3808409372965494e-05 minutes finish epoch 40 for 1.3530254364013672e-05 minutes finish epoch 41 for 1.413424809773763e-05 minutes finish epoch 42 for 1.4328956604003907e-05 minutes finish epoch 43 for 1.384417215983073e-05 minutes finish epoch 44 for 1.3724962870279949e-05 minutes finish epoch 45 for 1.366138458251953e-05 minutes finish epoch 46 for 1.3685226440429687e-05 minutes finish epoch 47 for 1.4328956604003907e-05 minutes finish epoch 48 for 1.373291015625e-05 minutes finish epoch 49 for 1.373291015625e-05 minutes episode 151 episode 152 episode 153 episode 154 episode 155 episode 156 episode 157 episode 158 episode 159 episode 160 episode 161 episode 162 episode 163 episode 164 episode 165 episode 166 episode 167 episode 168 episode 169 episode 170 episode 171 episode 172 episode 173 episode 174 episode 175 episode 176 episode 177 episode 178 episode 179 episode 180 epsiode 180 training... finish epoch 0 for 2.583662668863932e-05 minutes finish epoch 1 for 1.441637674967448e-05 minutes finish epoch 2 for 1.4146169026692709e-05 minutes finish epoch 3 for 1.575946807861328e-05 minutes finish epoch 4 for 1.4142195383707683e-05 minutes finish epoch 5 for 1.413424809773763e-05 minutes finish epoch 6 for 1.4122327168782552e-05 minutes finish epoch 7 for 1.3466676076253255e-05 minutes finish epoch 8 for 1.4217694600423177e-05 minutes finish epoch 9 for 1.436471939086914e-05 minutes finish epoch 10 for 1.4173984527587891e-05 minutes finish epoch 11 for 1.3788541158040365e-05 minutes finish epoch 12 for 1.377264658610026e-05 minutes finish epoch 13 for 1.4372666676839192e-05 minutes finish epoch 14 for 1.4603137969970703e-05 minutes finish epoch 15 for 1.4082590738932292e-05 minutes finish epoch 16 for 1.337130864461263e-05 minutes finish epoch 17 for 1.441637674967448e-05 minutes finish epoch 18 for 1.3856093088785807e-05 minutes finish epoch 19 for 1.4440218607584636e-05 minutes finish epoch 20 for 1.398324966430664e-05 minutes finish epoch 21 for 1.3343493143717448e-05 minutes finish epoch 22 for 1.5695889790852863e-05 minutes finish epoch 23 for 1.4352798461914063e-05 minutes finish epoch 24 for 1.3999144236246745e-05 minutes finish epoch 25 for 1.3879934946695964e-05 minutes finish epoch 26 for 1.362164815266927e-05 minutes finish epoch 27 for 1.4559427897135417e-05 minutes finish epoch 28 for 1.4396508534749349e-05 minutes finish epoch 29 for 1.3939539591471355e-05 minutes finish epoch 30 for 1.3788541158040365e-05 minutes finish epoch 31 for 1.3919671376546224e-05 minutes finish epoch 32 for 1.3724962870279949e-05 minutes finish epoch 33 for 1.432498296101888e-05 minutes finish epoch 34 for 1.378456751505534e-05 minutes finish epoch 35 for 1.375277837117513e-05 minutes finish epoch 36 for 1.3796488444010417e-05 minutes finish epoch 37 for 1.4495849609375e-05 minutes finish epoch 38 for 1.4026959737141928e-05 minutes finish epoch 39 for 1.388390858968099e-05 minutes finish epoch 40 for 1.3653437296549479e-05 minutes finish epoch 41 for 1.3935565948486329e-05 minutes finish epoch 42 for 1.4197826385498046e-05 minutes finish epoch 43 for 1.3808409372965494e-05 minutes finish epoch 44 for 1.350243886311849e-05 minutes finish epoch 45 for 1.3828277587890625e-05 minutes finish epoch 46 for 1.3907750447591146e-05 minutes finish epoch 47 for 1.4269351959228516e-05 minutes finish epoch 48 for 1.3744831085205078e-05 minutes finish epoch 49 for 1.3192494710286459e-05 minutes episode 181 episode 182 episode 183 episode 184 episode 185 episode 186 episode 187 episode 188 episode 189 episode 190 episode 191 episode 192 episode 193 episode 194 episode 195 episode 196 episode 197 episode 198 episode 199 episode 200 episode 201 episode 202 episode 203 episode 204 episode 205 episode 206 episode 207 episode 208 episode 209 episode 210 epsiode 210 training... finish epoch 0 for 2.6905536651611327e-05 minutes finish epoch 1 for 1.6208489735921224e-05 minutes finish epoch 2 for 1.4619032541910808e-05 minutes finish epoch 3 for 1.4003117879231771e-05 minutes finish epoch 4 for 1.4086564381917318e-05 minutes finish epoch 5 for 1.534620920817057e-05 minutes finish epoch 6 for 1.4491875966389974e-05 minutes finish epoch 7 for 1.4078617095947265e-05 minutes finish epoch 8 for 1.3573964436848958e-05 minutes finish epoch 9 for 1.3701121012369792e-05 minutes finish epoch 10 for 1.430511474609375e-05 minutes finish epoch 11 for 1.4543533325195312e-05 minutes finish epoch 12 for 1.4026959737141928e-05 minutes finish epoch 13 for 1.3399124145507813e-05 minutes finish epoch 14 for 1.3987223307291666e-05 minutes finish epoch 15 for 1.3927618662516275e-05 minutes finish epoch 16 for 1.581907272338867e-05 minutes finish epoch 17 for 1.4535586039225261e-05 minutes finish epoch 18 for 1.3613700866699219e-05 minutes finish epoch 19 for 1.4313062032063802e-05 minutes finish epoch 20 for 1.4162063598632812e-05 minutes finish epoch 21 for 1.4070669809977213e-05 minutes finish epoch 22 for 1.436471939086914e-05 minutes finish epoch 23 for 1.3577938079833985e-05 minutes finish epoch 24 for 1.4189879099527995e-05 minutes finish epoch 25 for 1.4146169026692709e-05 minutes finish epoch 26 for 1.4042854309082031e-05 minutes finish epoch 27 for 1.3510386149088541e-05 minutes finish epoch 28 for 1.398324966430664e-05 minutes finish epoch 29 for 1.3971328735351563e-05 minutes finish epoch 30 for 1.4491875966389974e-05 minutes finish epoch 31 for 1.3407071431477865e-05 minutes finish epoch 32 for 1.360177993774414e-05 minutes finish epoch 33 for 1.4030933380126953e-05 minutes finish epoch 34 for 1.4185905456542969e-05 minutes finish epoch 35 for 1.3931592305501301e-05 minutes finish epoch 36 for 1.3510386149088541e-05 minutes finish epoch 37 for 1.3645490010579427e-05 minutes finish epoch 38 for 1.4742215474446615e-05 minutes finish epoch 39 for 1.4519691467285156e-05 minutes finish epoch 40 for 1.3919671376546224e-05 minutes finish epoch 41 for 1.3868014017740885e-05 minutes finish epoch 42 for 1.3979276021321614e-05 minutes finish epoch 43 for 1.4861424763997396e-05 minutes finish epoch 44 for 1.4317035675048827e-05 minutes finish epoch 45 for 1.3879934946695964e-05 minutes finish epoch 46 for 1.38243039449056e-05 minutes finish epoch 47 for 1.413424809773763e-05 minutes finish epoch 48 for 1.436471939086914e-05 minutes finish epoch 49 for 1.3848145802815756e-05 minutes episode 211 episode 212 episode 213 episode 214 episode 215 episode 216 episode 217 episode 218 episode 219 episode 220 episode 221 episode 222 episode 223 episode 224 episode 225 episode 226 episode 227 episode 228 episode 229 episode 230 episode 231 episode 232 episode 233 episode 234 episode 235 episode 236 episode 237 episode 238 episode 239 episode 240 epsiode 240 training... finish epoch 0 for 2.5383631388346355e-05 minutes finish epoch 1 for 1.4460086822509765e-05 minutes finish epoch 2 for 1.4845530192057291e-05 minutes finish epoch 3 for 1.4543533325195312e-05 minutes finish epoch 4 for 1.4110406239827473e-05 minutes finish epoch 5 for 1.3915697733561198e-05 minutes finish epoch 6 for 1.4253457387288411e-05 minutes finish epoch 7 for 1.3804435729980468e-05 minutes finish epoch 8 for 1.4440218607584636e-05 minutes finish epoch 9 for 1.403490702311198e-05 minutes finish epoch 10 for 1.3307730356852214e-05 minutes finish epoch 11 for 1.4102458953857422e-05 minutes finish epoch 12 for 1.4722347259521484e-05 minutes finish epoch 13 for 1.375277837117513e-05 minutes finish epoch 14 for 1.432498296101888e-05 minutes finish epoch 15 for 1.713434855143229e-05 minutes finish epoch 16 for 1.3736883799235026e-05 minutes finish epoch 17 for 1.4491875966389974e-05 minutes finish epoch 18 for 1.4146169026692709e-05 minutes finish epoch 19 for 1.3267993927001953e-05 minutes finish epoch 20 for 1.3999144236246745e-05 minutes finish epoch 21 for 1.3649463653564453e-05 minutes finish epoch 22 for 1.4229615529378254e-05 minutes finish epoch 23 for 1.4070669809977213e-05 minutes finish epoch 24 for 1.3327598571777343e-05 minutes finish epoch 25 for 1.4090538024902344e-05 minutes finish epoch 26 for 1.4301141103108724e-05 minutes finish epoch 27 for 1.3736883799235026e-05 minutes finish epoch 28 for 1.383225123087565e-05 minutes finish epoch 29 for 1.3717015584309895e-05 minutes finish epoch 30 for 1.3609727223714193e-05 minutes finish epoch 31 for 1.4213720957438151e-05 minutes finish epoch 32 for 1.4026959737141928e-05 minutes finish epoch 33 for 1.3315677642822266e-05 minutes finish epoch 34 for 1.3633569081624348e-05 minutes finish epoch 35 for 1.3530254364013672e-05 minutes finish epoch 36 for 1.4301141103108724e-05 minutes finish epoch 37 for 1.4003117879231771e-05 minutes finish epoch 38 for 1.345078150431315e-05 minutes finish epoch 39 for 1.4070669809977213e-05 minutes finish epoch 40 for 1.3669331868489584e-05 minutes finish epoch 41 for 1.4098485310872396e-05 minutes finish epoch 42 for 1.3955434163411458e-05 minutes finish epoch 43 for 1.360177993774414e-05 minutes finish epoch 44 for 1.4086564381917318e-05 minutes finish epoch 45 for 1.4408429463704426e-05 minutes finish epoch 46 for 1.3820330301920573e-05 minutes finish epoch 47 for 1.387198766072591e-05 minutes finish epoch 48 for 1.3204415639241536e-05 minutes finish epoch 49 for 1.3891855875651041e-05 minutes episode 241 episode 242 episode 243 episode 244 episode 245 episode 246 episode 247 episode 248 episode 249 episode 250 episode 251 episode 252 episode 253 episode 254 episode 255 episode 256 episode 257 episode 258 episode 259 episode 260 episode 261 episode 262 episode 263 episode 264 episode 265 episode 266 episode 267 episode 268 episode 269 episode 270 epsiode 270 training... finish epoch 0 for 2.4863084157307942e-05 minutes finish epoch 1 for 1.4678637186686199e-05 minutes finish epoch 2 for 1.4022986094156902e-05 minutes finish epoch 3 for 1.4980634053548178e-05 minutes finish epoch 4 for 1.398324966430664e-05 minutes finish epoch 5 for 1.4380613962809246e-05 minutes finish epoch 6 for 1.3800462086995443e-05 minutes finish epoch 7 for 1.4086564381917318e-05 minutes finish epoch 8 for 1.3494491577148438e-05 minutes finish epoch 9 for 1.3780593872070312e-05 minutes finish epoch 10 for 1.434485117594401e-05 minutes finish epoch 11 for 1.3820330301920573e-05 minutes finish epoch 12 for 1.3744831085205078e-05 minutes finish epoch 13 for 1.3724962870279949e-05 minutes finish epoch 14 for 1.4070669809977213e-05 minutes finish epoch 15 for 1.3808409372965494e-05 minutes finish epoch 16 for 1.3093153635660807e-05 minutes finish epoch 17 for 1.3804435729980468e-05 minutes finish epoch 18 for 1.394351323445638e-05 minutes finish epoch 19 for 1.4392534891764323e-05 minutes finish epoch 20 for 1.3828277587890625e-05 minutes finish epoch 21 for 1.356204350789388e-05 minutes finish epoch 22 for 1.3709068298339844e-05 minutes finish epoch 23 for 1.377264658610026e-05 minutes finish epoch 24 for 1.4313062032063802e-05 minutes finish epoch 25 for 1.3709068298339844e-05 minutes finish epoch 26 for 1.3486544291178386e-05 minutes finish epoch 27 for 1.387198766072591e-05 minutes finish epoch 28 for 1.3641516367594401e-05 minutes finish epoch 29 for 1.4197826385498046e-05 minutes finish epoch 30 for 1.3756752014160157e-05 minutes finish epoch 31 for 1.3744831085205078e-05 minutes finish epoch 32 for 1.3534228006998698e-05 minutes finish epoch 33 for 1.4086564381917318e-05 minutes finish epoch 34 for 1.3724962870279949e-05 minutes finish epoch 35 for 1.3518333435058594e-05 minutes finish epoch 36 for 1.383225123087565e-05 minutes finish epoch 37 for 1.405477523803711e-05 minutes finish epoch 38 for 1.4181931813557943e-05 minutes finish epoch 39 for 1.3697147369384766e-05 minutes finish epoch 40 for 1.3260046641031901e-05 minutes finish epoch 41 for 1.3677279154459636e-05 minutes finish epoch 42 for 1.4142195383707683e-05 minutes finish epoch 43 for 1.4336903889973958e-05 minutes finish epoch 44 for 1.3665358225504558e-05 minutes finish epoch 45 for 1.3840198516845702e-05 minutes finish epoch 46 for 1.3558069864908854e-05 minutes finish epoch 47 for 1.3840198516845702e-05 minutes finish epoch 48 for 1.4464060465494791e-05 minutes finish epoch 49 for 1.3617674509684245e-05 minutes episode 271 episode 272 episode 273 episode 274 episode 275 episode 276 episode 277 episode 278 episode 279 episode 280 episode 281 episode 282 episode 283 episode 284 episode 285 episode 286 episode 287 episode 288 episode 289 episode 290 episode 291 episode 292 episode 293 episode 294 episode 295 episode 296 episode 297 episode 298 episode 299 episode 300
INFO:root:finish save agent256_512_1_latest
epsiode 300 training... finish epoch 0 for 2.52683957417806e-05 minutes finish epoch 1 for 1.5862782796223958e-05 minutes finish epoch 2 for 1.4519691467285156e-05 minutes finish epoch 3 for 1.3625621795654297e-05 minutes finish epoch 4 for 1.3720989227294921e-05 minutes finish epoch 5 for 1.424551010131836e-05 minutes finish epoch 6 for 1.3963381449381511e-05 minutes finish epoch 7 for 1.4730294545491536e-05 minutes finish epoch 8 for 1.333157221476237e-05 minutes finish epoch 9 for 1.4015038808186849e-05 minutes finish epoch 10 for 1.4162063598632812e-05 minutes finish epoch 11 for 1.3836224873860677e-05 minutes finish epoch 12 for 1.3895829518636067e-05 minutes finish epoch 13 for 1.3864040374755859e-05 minutes finish epoch 14 for 1.383225123087565e-05 minutes finish epoch 15 for 1.4332930246988932e-05 minutes finish epoch 16 for 1.4297167460123698e-05 minutes finish epoch 17 for 1.3764699300130209e-05 minutes finish epoch 18 for 1.3641516367594401e-05 minutes finish epoch 19 for 1.3343493143717448e-05 minutes finish epoch 20 for 1.4583269755045572e-05 minutes finish epoch 21 for 1.445611317952474e-05 minutes finish epoch 22 for 1.3597806294759114e-05 minutes finish epoch 23 for 1.3581911722819011e-05 minutes finish epoch 24 for 1.3633569081624348e-05 minutes finish epoch 25 for 1.3597806294759114e-05 minutes finish epoch 26 for 1.4142195383707683e-05 minutes finish epoch 27 for 1.3605753580729167e-05 minutes finish epoch 28 for 1.3438860575358073e-05 minutes finish epoch 29 for 1.4197826385498046e-05 minutes finish epoch 30 for 1.4146169026692709e-05 minutes finish epoch 31 for 1.3756752014160157e-05 minutes finish epoch 32 for 1.3717015584309895e-05 minutes finish epoch 33 for 1.3518333435058594e-05 minutes finish epoch 34 for 1.5580654144287108e-05 minutes finish epoch 35 for 1.428524653116862e-05 minutes finish epoch 36 for 1.3764699300130209e-05 minutes finish epoch 37 for 1.3514359792073567e-05 minutes finish epoch 38 for 1.354217529296875e-05 minutes finish epoch 39 for 1.3605753580729167e-05 minutes finish epoch 40 for 1.432498296101888e-05 minutes finish epoch 41 for 1.3836224873860677e-05 minutes finish epoch 42 for 1.3550122578938803e-05 minutes finish epoch 43 for 1.378456751505534e-05 minutes finish epoch 44 for 1.3665358225504558e-05 minutes finish epoch 45 for 1.4368693033854166e-05 minutes finish epoch 46 for 1.3709068298339844e-05 minutes finish epoch 47 for 1.318057378133138e-05 minutes finish epoch 48 for 1.3959407806396484e-05 minutes finish epoch 49 for 1.42057736714681e-05 minutes
Out[18]:
('data/256_512_1_latest', '256_512_1_latest')
In [19]:
Copied!
NN_path = retro_rl_agent.save("latest")
NN_path = retro_rl_agent.save("latest")
INFO:root:finish save agent256_512_1_latest
Step 4: PostProcess Result¶
In [21]:
Copied!
target = 'COC(Cc1ccc2oc(Cc3nc(-c4ccccc4)oc3C)cc2c1)OC'
retro_rl_agent.pathway(target)
layer2 = retro_rl_agent.layer2
# print(layer2)
path = set()
for i, j in layer2.items():
for k, l in j.items():
path.add(l)
print(f"The path of retro_rl_agent: \n \
{path}")
input_data_path = agent_param["data_path"]
ground_truth = np.load(input_data_path+'/ground_truth.npy', allow_pickle=True).tolist()
real_path = set(ground_truth[target]['path'])
print(f"The real_path of Brute force: \n \
{real_path}")
real_cost = ground_truth[target]['cost']
print(f"The real_cost of Brute force: \n \
{real_cost}")
print(f"Get the same path: {path == real_path}")
target = 'COC(Cc1ccc2oc(Cc3nc(-c4ccccc4)oc3C)cc2c1)OC'
retro_rl_agent.pathway(target)
layer2 = retro_rl_agent.layer2
# print(layer2)
path = set()
for i, j in layer2.items():
for k, l in j.items():
path.add(l)
print(f"The path of retro_rl_agent: \n \
{path}")
input_data_path = agent_param["data_path"]
ground_truth = np.load(input_data_path+'/ground_truth.npy', allow_pickle=True).tolist()
real_path = set(ground_truth[target]['path'])
print(f"The real_path of Brute force: \n \
{real_path}")
real_cost = ground_truth[target]['cost']
print(f"The real_cost of Brute force: \n \
{real_cost}")
print(f"Get the same path: {path == real_path}")
The path of retro_rl_agent: {'COC=Cc1ccc2oc(Cc3nc(-c4ccccc4)oc3C)cc2c1', 'Cc1ccc(S(=O)(=O)O)cc1', 'O=C(O)[C@@H]1CCCN1', 'O=[N+]([O-])c1ccc(CO)cc1', 'COC(Cc1ccc2oc(Cc3nc(-c4ccccc4)oc3C)cc2c1)OC'} The real_path of Brute force: {'COC=Cc1ccc2oc(Cc3nc(-c4ccccc4)oc3C)cc2c1', 'Cc1ccc(S(=O)(=O)O)cc1', 'O=C(O)[C@@H]1CCCN1', 'O=[N+]([O-])c1ccc(CO)cc1', 'COC(Cc1ccc2oc(Cc3nc(-c4ccccc4)oc3C)cc2c1)OC'} The real_cost of Brute force: 102.0 Get the same path: True
In [22]:
Copied!
target = 'O=C(NCc1ccc(CO)cc1)c1ccccn1'
retro_rl_agent.pathway(target)
layer2 = retro_rl_agent.layer2
# print(layer2)
path = set()
for i, j in layer2.items():
for k, l in j.items():
path.add(l)
print(f"The path of retro_rl_agent: \n \
{path}")
input_data_path = agent_param["data_path"]
ground_truth = np.load(input_data_path+'/ground_truth.npy', allow_pickle=True).tolist()
real_path = set(ground_truth[target]['path'])
print(f"The real_path of Brute force: \n \
{real_path}")
real_cost = ground_truth[target]['cost']
print(f"The real_cost of Brute force: \n \
{real_cost}")
print(f"Get the same path: {path == real_path}")
target = 'O=C(NCc1ccc(CO)cc1)c1ccccn1'
retro_rl_agent.pathway(target)
layer2 = retro_rl_agent.layer2
# print(layer2)
path = set()
for i, j in layer2.items():
for k, l in j.items():
path.add(l)
print(f"The path of retro_rl_agent: \n \
{path}")
input_data_path = agent_param["data_path"]
ground_truth = np.load(input_data_path+'/ground_truth.npy', allow_pickle=True).tolist()
real_path = set(ground_truth[target]['path'])
print(f"The real_path of Brute force: \n \
{real_path}")
real_cost = ground_truth[target]['cost']
print(f"The real_cost of Brute force: \n \
{real_cost}")
print(f"Get the same path: {path == real_path}")
The path of retro_rl_agent: {'O=C(O)c1ccccn1', 'N#Cc1ccc(C=O)cc1', 'N#Cc1ccc(CO)cc1', 'O=C(NCc1ccc(CO)cc1)c1ccccn1', 'NCc1ccc(CO)cc1'} The real_path of Brute force: {'O=C(O)c1ccccn1', 'N#Cc1ccc(C=O)cc1', 'N#Cc1ccc(CO)cc1', 'O=C(NCc1ccc(CO)cc1)c1ccccn1', 'NCc1ccc(CO)cc1'} The real_cost of Brute force: 3.0 Get the same path: True
In [23]:
Copied!
target = 'CCCCC(CC)COC(=O)C(C#N)=C(c1ccccc1)c1ccccc1'
retro_rl_agent.pathway(target)
layer2 = retro_rl_agent.layer2
# print(layer2)
path = set()
for i, j in layer2.items():
for k, l in j.items():
path.add(l)
print(f"The path of retro_rl_agent: \n \
{path}")
input_data_path = agent_param["data_path"]
ground_truth = np.load(input_data_path+'/ground_truth.npy', allow_pickle=True).tolist()
real_path = set(ground_truth[target]['path'])
print(f"The real_path of Brute force: \n \
{real_path}")
real_cost = ground_truth[target]['cost']
print(f"The real_cost of Brute force: \n \
{real_cost}")
print(f"Get the same path: {path == real_path}")
target = 'CCCCC(CC)COC(=O)C(C#N)=C(c1ccccc1)c1ccccc1'
retro_rl_agent.pathway(target)
layer2 = retro_rl_agent.layer2
# print(layer2)
path = set()
for i, j in layer2.items():
for k, l in j.items():
path.add(l)
print(f"The path of retro_rl_agent: \n \
{path}")
input_data_path = agent_param["data_path"]
ground_truth = np.load(input_data_path+'/ground_truth.npy', allow_pickle=True).tolist()
real_path = set(ground_truth[target]['path'])
print(f"The real_path of Brute force: \n \
{real_path}")
real_cost = ground_truth[target]['cost']
print(f"The real_cost of Brute force: \n \
{real_cost}")
print(f"Get the same path: {path == real_path}")
The path of retro_rl_agent: {'CCCCC(CC)COC(=O)C(C#N)=C(c1ccccc1)c1ccccc1', 'O=C(Cl)c1ccccc1', 'O=C(c1ccccc1)c1ccccc1', 'c1ccccc1', 'CCCCC(CC)COC(=O)CC#N'} The real_path of Brute force: {'CCCCC(CC)COC(=O)C(C#N)=C(c1ccccc1)c1ccccc1', 'O=C(Cl)c1ccccc1', 'O=C(c1ccccc1)c1ccccc1', 'c1ccccc1', 'CCCCC(CC)COC(=O)CC#N'} The real_cost of Brute force: 2.0 Get the same path: True
Hybrid Job Experiment¶
In [1]:
Copied!
from braket.aws import AwsQuantumJob
from braket.jobs.config import InstanceConfig
import boto3
import json
import time
import altair as alt
import pandas as pd
import numpy as np
from hybridjobs.utility.HybridJobHelpers import *
from braket.aws import AwsQuantumJob
from braket.jobs.config import InstanceConfig
import boto3
import json
import time
import altair as alt
import pandas as pd
import numpy as np
from hybridjobs.utility.HybridJobHelpers import *
Step 1: Prepare parameters for batch evaluation¶
In this part, we set the parameters for batch evaluation
In [2]:
Copied!
# parameters for experiments
experiment_name = "retrosynthetic-planning"
data_path = "retrosynthetic-planning-data"
suffix_check = ["txt"]
experiments_params = {
"version": "1",
"params": [
{"n_qubits": [8]},
{"framework": ['pennylane']},
{"layers": [1,2,3]},
{"shots": [100]},
{"device": ['local']}
]
}
hp = {}
hybrid_job_params = []
parse_params(experiments_params['params'], hp, hybrid_job_params)
print(f"parameters for experiments: \n {hybrid_job_params}")
# parameters for experiments
experiment_name = "retrosynthetic-planning"
data_path = "retrosynthetic-planning-data"
suffix_check = ["txt"]
experiments_params = {
"version": "1",
"params": [
{"n_qubits": [8]},
{"framework": ['pennylane']},
{"layers": [1,2,3]},
{"shots": [100]},
{"device": ['local']}
]
}
hp = {}
hybrid_job_params = []
parse_params(experiments_params['params'], hp, hybrid_job_params)
print(f"parameters for experiments: \n {hybrid_job_params}")
parameters for experiments: [{'n_qubits': 8, 'framework': 'pennylane', 'layers': 1, 'shots': 100, 'device': 'local'}, {'n_qubits': 8, 'framework': 'pennylane', 'layers': 2, 'shots': 100, 'device': 'local'}, {'n_qubits': 8, 'framework': 'pennylane', 'layers': 3, 'shots': 100, 'device': 'local'}]
In [3]:
Copied!
# parameters for experiments
experiment_name = "retrosynthetic-planning"
data_path = "retrosynthetic-planning-data"
suffix_check = ["txt"]
experiments_params = {
"version": "1",
"params1": [
{"n_qubits": [8]},
{"framework": ['pennylane']},
{"layers": [1,2,3]},
{"shots": [100,1000]},
{"device": ['local']}
],
"params2": [
{"inputsize": [256]},
{"middlesize": [256,512,1024]},
{"outputsize": [1]}
]
}
# hp = {}
# hybrid_job_params = []
# parse_params(experiments_params['params'], hp, hybrid_job_params)
# print(f"parameters for experiments: \n {hybrid_job_params}")
hybrid_job_params = []
for n_qubits in experiments_params['params1'][0]["n_qubits"]:
for framework in experiments_params['params1'][1]["framework"]:
for layers in experiments_params['params1'][2]["layers"]:
for shots in experiments_params['params1'][3]["shots"]:
for device in experiments_params['params1'][4]["device"]:
model_name = "{}_{}_{}_{}_{}".format(n_qubits, device, framework, shots, layers)
hybrid_job_params.append(model_name)
for inputsize in experiments_params['params2'][0]["inputsize"]:
for middlesize in experiments_params['params2'][1]["middlesize"]:
for outputsize in experiments_params['params2'][2]["outputsize"]:
model_name = "{}_{}_{}".format(inputsize, middlesize, outputsize)
hybrid_job_params.append(model_name)
# parameters for experiments
experiment_name = "retrosynthetic-planning"
data_path = "retrosynthetic-planning-data"
suffix_check = ["txt"]
experiments_params = {
"version": "1",
"params1": [
{"n_qubits": [8]},
{"framework": ['pennylane']},
{"layers": [1,2,3]},
{"shots": [100,1000]},
{"device": ['local']}
],
"params2": [
{"inputsize": [256]},
{"middlesize": [256,512,1024]},
{"outputsize": [1]}
]
}
# hp = {}
# hybrid_job_params = []
# parse_params(experiments_params['params'], hp, hybrid_job_params)
# print(f"parameters for experiments: \n {hybrid_job_params}")
hybrid_job_params = []
for n_qubits in experiments_params['params1'][0]["n_qubits"]:
for framework in experiments_params['params1'][1]["framework"]:
for layers in experiments_params['params1'][2]["layers"]:
for shots in experiments_params['params1'][3]["shots"]:
for device in experiments_params['params1'][4]["device"]:
model_name = "{}_{}_{}_{}_{}".format(n_qubits, device, framework, shots, layers)
hybrid_job_params.append(model_name)
for inputsize in experiments_params['params2'][0]["inputsize"]:
for middlesize in experiments_params['params2'][1]["middlesize"]:
for outputsize in experiments_params['params2'][2]["outputsize"]:
model_name = "{}_{}_{}".format(inputsize, middlesize, outputsize)
hybrid_job_params.append(model_name)
In [4]:
Copied!
hybrid_job_params
hybrid_job_params
Out[4]:
['8_local_pennylane_100_1', '8_local_pennylane_1000_1', '8_local_pennylane_100_2', '8_local_pennylane_1000_2', '8_local_pennylane_100_3', '8_local_pennylane_1000_3', '256_256_1', '256_512_1', '256_1024_1']
In [6]:
Copied!
avtocost = []
model_path = "./retrorl_model_latest.pickle"
for i in hybrid_job_params:
# model_name = hybrid_job_params[i]
model_name = i
if model_name[0] == "8":
method = "retro-qrl"
else:
method = "retro-rl"
# train_mode can be: "local-instance", "local-job", "hybrid-job"
train_mode = "local-instance"
data_path = 'data'
agent_param = {}
agent_param["data_path"] = data_path
agent_param["train_mode"] = train_mode
agent_param["model_name"] = model_name
agent_param["model_path"] = model_path
retro_model = None
if train_mode == "local-instance":
# get model
retro_rl_model = RetroRLModel.load(model_path)
model_info = retro_rl_model.describe_model()
retro_model = retro_rl_model.get_model(method, model_name)
retro_rl_agent = RetroRLAgent(retro_model, method, **agent_param)
retro_rl_agent.game_job()
avtocost.append(retro_rl_agent.avtocost)
avtocost = []
model_path = "./retrorl_model_latest.pickle"
for i in hybrid_job_params:
# model_name = hybrid_job_params[i]
model_name = i
if model_name[0] == "8":
method = "retro-qrl"
else:
method = "retro-rl"
# train_mode can be: "local-instance", "local-job", "hybrid-job"
train_mode = "local-instance"
data_path = 'data'
agent_param = {}
agent_param["data_path"] = data_path
agent_param["train_mode"] = train_mode
agent_param["model_name"] = model_name
agent_param["model_path"] = model_path
retro_model = None
if train_mode == "local-instance":
# get model
retro_rl_model = RetroRLModel.load(model_path)
model_info = retro_rl_model.describe_model()
retro_model = retro_rl_model.get_model(method, model_name)
retro_rl_agent = RetroRLAgent(retro_model, method, **agent_param)
retro_rl_agent.game_job()
avtocost.append(retro_rl_agent.avtocost)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[6], line 25 22 retro_model = None 23 if train_mode == "local-instance": 24 # get model ---> 25 retro_rl_model = RetroRLModel.load(model_path) 26 model_info = retro_rl_model.describe_model() 27 retro_model = retro_rl_model.get_model(method, model_name) NameError: name 'RetroRLModel' is not defined
In [ ]:
Copied!
# draw the training curve
import matplotlib.pyplot as plt
plt.figure(1)
plt.title('Training curve')
plt.xlabel('Epoch')
plt.ylabel('Average cost')
for i in range(len(hybrid_job_params)):
plt.plot(range(0,len(avtocost[0])),avtocost[i],label=hybrid_job_params[i])
plt.legend(loc = 'upper right')
# draw the training curve
import matplotlib.pyplot as plt
plt.figure(1)
plt.title('Training curve')
plt.xlabel('Epoch')
plt.ylabel('Average cost')
for i in range(len(hybrid_job_params)):
plt.plot(range(0,len(avtocost[0])),avtocost[i],label=hybrid_job_params[i])
plt.legend(loc = 'upper right')