Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Troubled Cell Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
97f6c885
Commit
97f6c885
authored
3 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Ensured repeatable output through seeds and deterministic models.
parent
1449ed05
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
ANN_Training.py
+7
-0
7 additions, 0 deletions
ANN_Training.py
Snakefile
+0
-4
0 additions, 4 deletions
Snakefile
workflows/ANN_training.smk
+7
-11
7 additions, 11 deletions
workflows/ANN_training.smk
workflows/approximation.smk
+0
-4
0 additions, 4 deletions
workflows/approximation.smk
with
14 additions
and
19 deletions
ANN_Training.py
+
7
−
0
View file @
97f6c885
...
...
@@ -71,6 +71,13 @@ class ModelTrainer:
self
.
_num_epochs
=
config
.
pop
(
'
num_epochs
'
,
1000
)
self
.
_threshold
=
config
.
pop
(
'
threshold
'
,
1e-5
)
# Set random seed
seed
=
config
.
pop
(
'
random_seed
'
,
None
)
if
seed
is
not
None
:
np
.
random
.
seed
(
seed
)
torch
.
manual_seed
(
seed
)
torch
.
use_deterministic_algorithms
(
True
)
model
=
config
.
pop
(
'
model
'
,
'
ThreeLayerReLu
'
)
model_config
=
config
.
pop
(
'
model_config
'
,
{})
loss_function
=
config
.
pop
(
'
loss_function
'
,
'
BCELoss
'
)
...
...
This diff is collapsed.
Click to expand it.
Snakefile
+
0
−
4
View file @
97f6c885
import numpy as np
configfile: 'config.yaml'
DIR = 'workflows'
if config['random_seed'] is not None:
np.random.seed(config['random_seed'])
module_config = {'data_dir': config['data_dir'],
'random_seed': config['random_seed']}
...
...
This diff is collapsed.
Click to expand it.
workflows/ANN_training.smk
+
7
−
11
View file @
97f6c885
import sys
import numpy as np
import ANN_Training
from ANN_Training import *
...
...
@@ -9,8 +8,6 @@ configfile: 'config.yaml'
DIR = config['data_dir']
MODELS = config['models']
if config['random_seed'] is not None:
np.random.seed(config['random_seed'])
rule all:
input:
...
...
@@ -30,15 +27,9 @@ rule plot_test_results:
log:
DIR+'/log/plot_test_results.log'
run:
models = {}
with open(str(log), 'w') as logfile:
sys.stdout = logfile
sys.stderr = logfile
for model in MODELS:
trainer= ANN_Training.ModelTrainer(
{'model_name': model, 'dir': DIR, 'model_dir': DIR,
**MODELS[model]})
models[model] = trainer
plot_evaluation_results(evaluation_file=input.json_file,
directory=DIR, colors=params.colors)
...
...
@@ -52,7 +43,8 @@ rule test_model:
protected(DIR+'/model evaluation/'+'_'.join(MODELS.keys())+'.json')
params:
num_iterations = config['num_iterations'],
compare_normalization = config['compare_normalization']
compare_normalization = config['compare_normalization'],
random_seed = config['random_seed']
log:
DIR+'/log/test_model.log'
run:
...
...
@@ -63,6 +55,7 @@ rule test_model:
for model in MODELS:
trainer= ANN_Training.ModelTrainer(
{'model_name': model, 'dir': DIR, 'model_dir': DIR,
'random_seed': params.random_seed,
**MODELS[model]})
models[model] = trainer
evaluate_models(models=models, directory=DIR,
...
...
@@ -77,6 +70,8 @@ rule train_model:
output:
protected(DIR+'/trained models/{model}.model.pt'),
protected(DIR+'/trained models/{model}.loss.pt')
params:
random_seed = config['random_seed']
log:
DIR+'/log/train_model_{model}.log'
run:
...
...
@@ -84,6 +79,7 @@ rule train_model:
sys.stdout = logfile
training_data = read_training_data(DIR)
trainer= ANN_Training.ModelTrainer(
config={**MODELS[wildcards.model]})
config={'random_seed': params.random_seed,
**MODELS[wildcards.model]})
trainer.epoch_training(dataset=training_data)
trainer.save_model(directory=DIR, model_name=wildcards.model)
This diff is collapsed.
Click to expand it.
workflows/approximation.smk
+
0
−
4
View file @
97f6c885
import sys
import time
import numpy as np
import Initial_Condition
import Quadrature
from DG_Approximation import DGScheme
from Plotting import plot_approximation_results
from projection_utils import Mesh
configfile: 'config.yaml'
PLOTS = ['error', 'exact_and_approx', 'semilog_error', 'shock_tube']
DIR = config['data_dir']
SCHEMES = config['schemes']
if config['random_seed'] is not None:
np.random.seed(config['random_seed'])
rule all:
input:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment