FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

modify docs & modify the load strategy of neural networks when use pytorch by maorz1998 · Pull Request #151 · deepmodeling/deepflame-dev · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .dat  (2) .inp  (1) .json  (6) .pt  (3) .py  (1) .rst  (1) .yaml  (1) No extension  (2) All 8 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
    • inference.py
    • mechanisms
      • model5000.pt
      • norm.json
      • settings.json
      • model5000.pt
      • norm.json
      • settings.json
      • model5000.pt
      • norm.json
      • settings.json
      • ESH2.inp
      • ESH2.yaml
      • ESH2_thermo.dat
      • ESH2_transport.dat
4 changes: 2 additions & 2 deletions docs/source/qs/input.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Brief Introduction to Inputs
======================================
The dictionary ``CanteraTorchProperties`` is the original dictionay of DeepFlame. It read in netowrk realted parameters and configurations. It typically looks like:
The dictionary ``CanteraTorchProperties`` is the original dictionay of DeepFlame. It read in network related parameters and configurations. It typically looks like:

.. code-block::

Expand Down Expand Up @@ -28,7 +28,7 @@ The dictionary ``CanteraTorchProperties`` is the original dictionay of DeepFlame
torchModel1 "ESH2-sub1.pt";
torchModel2 "ESH2-sub2.pt";
torchModel3 "ESH2-sub3.pt";
coresPerGPU 4;
coresPerNode 4;

}
loadbalancing
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ splittingStrategy off;
TorchSettings
{
torch on;
GPU off;
GPU on;
log on;
torchModel1 "ESH2-sub1.pt";
torchModel2 "ESH2-sub2.pt";
torchModel3 "ESH2-sub3.pt";
torchModel "HE04_Hydrogen_ESH2_GMS_sub_20221101";
coresPerNode 4;
}

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,17 @@ def forward(self, x):
path_r = r"./constant/CanteraTorchProperties"
with open(path_r, "r") as f:
data = f.read()
i = data.index('torchModel1')
i = data.index('torchModel')
a = data.index('"',i)
b = data.index('.',a+1)
moduleName1 = data[a+1:b]

i = data.index('torchModel2')
a = data.index('"',i)
b = data.index('.',a+1)
moduleName2 = data[a+1:b]

i = data.index('torchModel3')
a = data.index('"',i)
b = data.index('.',a+1)
moduleName3 = data[a+1:b]
b = data.index('sub',a)
c = data.index('"',b+1)
modelName_split1 = data[a+1:b+3]
modelName_split2 = data[b+3:c]

modelPath = str(modelName_split1+modelName_split2)
model1Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"1"+modelName_split2+"/checkpoint/")
model2Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"2"+modelName_split2+"/checkpoint/")
model3Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"3"+modelName_split2+"/checkpoint/")

i = data.index('GPU')
a = data.index(';', i)
Expand All @@ -90,44 +87,51 @@ def forward(self, x):

#glbal variable will only init once when called interperter
#load parameters from json
setting0 = json2Parser(str("pytorchDNN/"+moduleName1+".json"))
setting1 = json2Parser(str("pytorchDNN/"+moduleName2+".json"))
setting2 = json2Parser(str("pytorchDNN/"+moduleName3+".json"))
#print(str("pytorchDNN/"+moduleName1+".json"))

norm0 = json2Parser(str(model1Path+"norm.json"))
norm1 = json2Parser(str(model2Path+"norm.json"))
norm2 = json2Parser(str(model3Path+"norm.json"))
setting0 = json2Parser(str(model1Path+"settings.json"))
lamda = setting0.power_transform
delta_t = setting0.delta_t
dim = setting0.dim
layers = setting0.layers


Xmu0 = torch.tensor(setting0.Xmu).unsqueeze(0).to(device)
Xstd0 = torch.tensor(setting0.Xstd).unsqueeze(0).to(device=device)
Ymu0 = torch.tensor(setting0.Ymu).unsqueeze(0).to(device=device)
Ystd0 = torch.tensor(setting0.Ystd).unsqueeze(0).to(device=device)
Xmu0 = torch.tensor(norm0.input_mean).unsqueeze(0).to(device=device)
Xstd0 = torch.tensor(norm0.input_std).unsqueeze(0).to(device=device)
Ymu0 = torch.tensor(norm0.label_mean).unsqueeze(0).to(device=device)
Ystd0 = torch.tensor(norm0.label_std).unsqueeze(0).to(device=device)

Xmu1 = torch.tensor(setting1.Xmu).unsqueeze(0).to(device=device)
Xstd1 = torch.tensor(setting1.Xstd).unsqueeze(0).to(device=device)
Ymu1 = torch.tensor(setting1.Ymu).unsqueeze(0).to(device=device)
Ystd1 = torch.tensor(setting1.Ystd).unsqueeze(0).to(device=device)
Xmu1 = torch.tensor(norm1.input_mean).unsqueeze(0).to(device=device)
Xstd1 = torch.tensor(norm1.input_std).unsqueeze(0).to(device=device)
Ymu1 = torch.tensor(norm1.label_mean).unsqueeze(0).to(device=device)
Ystd1 = torch.tensor(norm1.label_std).unsqueeze(0).to(device=device)

Xmu2 = torch.tensor(setting2.Xmu).unsqueeze(0).to(device=device)
Xstd2 = torch.tensor(setting2.Xstd).unsqueeze(0).to(device=device)
Ymu2 = torch.tensor(setting2.Ymu).unsqueeze(0).to(device=device)
Ystd2 = torch.tensor(setting2.Ystd).unsqueeze(0).to(device=device)
Xmu2 = torch.tensor(norm2.input_mean).unsqueeze(0).to(device=device)
Xstd2 = torch.tensor(norm2.input_std).unsqueeze(0).to(device=device)
Ymu2 = torch.tensor(norm2.label_mean).unsqueeze(0).to(device=device)
Ystd2 = torch.tensor(norm2.label_std).unsqueeze(0).to(device=device)

#load module
#load model
model0 = Net()
model1 = Net()
model2 = Net()

path_list=os.listdir(model1Path)
for filename in path_list:
if os.path.splitext(filename)[1] == '.pt':
modelname = filename


if torch.cuda.is_available()==False:
check_point0 = torch.load(str("pytorchDNN/"+moduleName1+".pt"), map_location='cpu')
check_point1 = torch.load(str("pytorchDNN/"+moduleName2+".pt"), map_location='cpu')
check_point2 = torch.load(str("pytorchDNN/"+moduleName3+".pt"), map_location='cpu')
check_point0 = torch.load(str(model1Path+modelname), map_location='cpu')
check_point1 = torch.load(str(model2Path+modelname), map_location='cpu')
check_point2 = torch.load(str(model3Path+modelname), map_location='cpu')
else:
check_point0 = torch.load(str("pytorchDNN/"+moduleName1+".pt"))
check_point1 = torch.load(str("pytorchDNN/"+moduleName2+".pt"))
check_point2 = torch.load(str("pytorchDNN/"+moduleName3+".pt"))
check_point0 = torch.load(str(model1Path+modelname))
check_point1 = torch.load(str(model2Path+modelname))
check_point2 = torch.load(str(model3Path+modelname))

model0.load_state_dict(check_point0)
model1.load_state_dict(check_point1)
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"input_mean":[
956.4666683951323,
1.2621251609602075,
-8.482865855078037,
-8.60195200775564,
-7.5687249938092975,
-8.739604352829021,
-3.0365348658864555,
-4.044646973729736,
-0.12868046894653598
],
"label_mean":[
115735.41509559377,
4.2646672113712347e-13,
8901.112679962635,
27135.624769093312,
30141.97503208172,
24712.755148584696,
-372.9651472886253,
-493.34322699725413,
-4.31138850114707e-12
],
"input_std":[
144.56082979138094,
0.4316114858005481,
1.3421800304159297,
1.3271564927376922,
1.964747648182199,
1.1993472911833807,
1.2594695379275647,
1.3518816605077604,
0.17392016053354714
],
"label_std":[
115735.41509559377,
1.1513875522375139e-10,
8901.112679962635,
27135.624769093312,
30141.97503208172,
24712.755148584696,
372.96514728862553,
493.3432269972544,
9.409165181242247e-11
]
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"seed":20,
"mech_path":"/home/yaojunjie/data/mechanism/ES80_H2-7-16.yaml",
"input_path":"/home/yaojunjie/data/ESH2/data/sub1-2/X.npy",
"label_path":"/home/yaojunjie/data/ESH2/data/sub1-2/Y.npy",
"shuffle":true,
"batch_size":1024,
"valid_batch_size":8192,
"train_size":10735978,
"valid_size":1192887,
"valid_ratio":0.1,
"prefetch":10,
"num_workers":16,
"pin_memory":true,
"power_transform":0.1,
"delta_t":1e-06,
"dim":9,
"layers":[
9,
1600,
800,
400,
9
],
"net_type":"fc",
"actfun":"CustomGELU",
"max_epoch":5000,
"epoch_decay":2500,
"learnrate":0.0001,
"lr_decay_rate":0.1,
"batch_grow_rate":128,
"lossfun":"L1",
"optim":"Adam",
"modelname":"HE04_Hydrogen_ESH2_sub1-2_20221028",
"model_path":"Model/HE04_Hydrogen_ESH2_sub1-2_20221028",
"device":"cuda:0",
"n_gpu":8,
"use_DP":false,
"use_DDP":true,
"local_rank":-1,
"world_size":8,
"backend":"nccl",
"description":"test",
"current_time":"2022-10-28 00:02:52"
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"input_mean": [
1933.118541482812,
1.2327983023706526,
-5.705591538151852,
-6.446971251373195,
-4.169802387800032,
-6.1200334699867165,
-4.266343396329115,
-2.6007437468608616,
-0.4049762774428252
],
"label_mean": [
6381847.837202463,
4.751063937334583e-14,
175072.98234441387,
125434.41067566245,
285397.9376620931,
172924.8443087139,
-97451.53428068386,
-7160.953630852251,
-9.791262408691773e-10
],
"input_std": [
716.6568054751183,
0.43268544913281914,
2.0857655247141387,
2.168997234412133,
2.707064105162402,
2.2681157746245897,
2.221785173612795,
1.5510851480805254,
0.30283229364455927
],
"label_std": [
6396799.801910002,
1.3523423408265769e-10,
179830.51132577812,
256152.83860126554,
285811.9455262339,
263600.5448448552,
98110.53711881173,
11752.979335965118,
4.0735353885293555e-09
]
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"seed": 2022,
"mech_path": "Chem/ESH2.yaml",
"input_path": "Data/ESH2/hydrogen_ESH2_642wGMS1_X.npy",
"label_path": "Data/ESH2/hydrogen_ESH2_642wGMS1_Y.npy",
"shuffle": true,
"batch_size": 1024,
"valid_batch_size": 8192,
"train_size": 5792898,
"valid_size": 643656,
"valid_ratio": 0.1,
"prefetch": 10,
"num_workers": 16,
"pin_memory": true,
"power_transform": 0.1,
"delta_t": 1e-06,
"dim": 9,
"layers": [
9,
1600,
800,
400,
9
],
"net_type": "fc",
"actfun": "CustomGELU",
"max_epoch": 5000,
"epoch_decay": 2500,
"learnrate": 0.0001,
"lr_decay_rate": 0.1,
"batch_grow_rate": 128,
"lossfun": "L1",
"optim": "Adam",
"modelname": "HE03_Hydrogen_ESH2_GMS_20221019",
"model_path": "Model/HE03_Hydrogen_ESH2_GMS_20221019",
"device": "cuda:6",
"n_gpu": 8,
"use_DP": false,
"use_DDP": false,
"local_rank": -1,
"world_size": 1,
"backend": "nccl",
"description": "ESH2 GMS1 Model",
"current_time": "2022-10-19 17:09:44"
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"input_mean":[
2717.141719004927,
1.2871371577864235,
-5.240181052513087,
-4.8947914078286345,
-3.117070179161789,
-4.346362771443917,
-4.657258124450032,
-4.537442872141596,
-0.11656950757756744
],
"label_mean":[
592947.6742955892,
5.1584233576272535e-14,
-611.0636921032669,
-915.1244682112174,
519.5930550881994,
-11.949500174512165,
-2660.9187297995336,
159.56360614662788,
-7.136459430073843e-11
],
"input_std":[
141.48030419772115,
0.4281422992061657,
0.6561518672685264,
0.9820405777881894,
1.0442969662425572,
0.7554583907448359,
1.7144519099198097,
1.1299391466695952,
0.15743252221610685
],
"label_std":[
592947.6742955892,
1.2527170559513018e-10,
611.0636921032669,
915.1244682112174,
519.5930550881994,
342.3100987934528,
2754.8463649064784,
313.3717647966624,
2.463374792192512e-10
]
}
Loading

Back | FazBrowse Home | New Git URL