Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
journal_eiv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jörg Martin
journal_eiv
Commits
e1584c1b
Commit
e1584c1b
authored
3 years ago
by
Jörg Martin
Browse files
Options
Downloads
Patches
Plain Diff
evaluate_tabular reads in JSON configuration
parent
03c02b18
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Experiments/evaluate_tabular.py
+32
-15
32 additions, 15 deletions
Experiments/evaluate_tabular.py
Experiments/train_noneiv.py
+2
-0
2 additions, 0 deletions
Experiments/train_noneiv.py
with
34 additions
and
15 deletions
Experiments/evaluate_tabular.py
+
32
−
15
View file @
e1584c1b
import
importlib
import
importlib
import
os
import
os
import
argparse
import
json
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
...
@@ -11,13 +13,27 @@ from EIVArchitectures import Networks
...
@@ -11,13 +13,27 @@ from EIVArchitectures import Networks
from
EIVTrainingRoutines
import
train_and_store
from
EIVTrainingRoutines
import
train_and_store
from
EIVGeneral.coverage_metrics
import
epistemic_coverage
,
normalized_std
from
EIVGeneral.coverage_metrics
import
epistemic_coverage
,
normalized_std
long_dataname
=
'
energy_efficiency
'
# read in data via --data option
short_dataname
=
'
energy
'
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
--data
"
,
help
=
"
Loads data
"
,
default
=
'
california
'
)
parser
.
add_argument
(
"
--no-autoindent
"
,
help
=
""
,
action
=
"
store_true
"
)
# to avoid conflics in IPython
args
=
parser
.
parse_args
()
data
=
args
.
data
# load hyperparameters from JSON file
with
open
(
os
.
path
.
join
(
'
configurations
'
,
f
'
eiv_
{
data
}
.json
'
),
'
r
'
)
as
conf_file
:
eiv_conf_dict
=
json
.
load
(
conf_file
)
with
open
(
os
.
path
.
join
(
'
configurations
'
,
f
'
noneiv_
{
data
}
.json
'
),
'
r
'
)
as
conf_file
:
noneiv_conf_dict
=
json
.
load
(
conf_file
)
long_dataname
=
eiv_conf_dict
[
"
long_dataname
"
]
short_dataname
=
eiv_conf_dict
[
"
short_dataname
"
]
print
(
f
"
Evaluating
{
long_dataname
}
"
)
scale_outputs
=
False
scale_outputs
=
False
load_data
=
importlib
.
import_module
(
f
'
EIVData.
{
long_dataname
}
'
).
load_data
load_data
=
importlib
.
import_module
(
f
'
EIVData.
{
long_dataname
}
'
).
load_data
train_noneiv
=
importlib
.
import_module
(
f
'
train_noneiv_
{
short_dataname
}
'
)
train_eiv
=
importlib
.
import_module
(
f
'
train_eiv_
{
short_dataname
}
'
)
train_data
,
test_data
=
load_data
()
train_data
,
test_data
=
load_data
()
input_dim
=
train_data
[
0
][
0
].
numel
()
input_dim
=
train_data
[
0
][
0
].
numel
()
...
@@ -50,10 +66,10 @@ def collect_metrics(x,y, seed=0,
...
@@ -50,10 +66,10 @@ def collect_metrics(x,y, seed=0,
# non-EiV
# non-EiV
noneiv_metrics
=
{}
noneiv_metrics
=
{}
init_std_y
=
train_noneiv
.
init_std_y_list
[
0
]
init_std_y
=
noneiv_conf_dict
[
"
init_std_y_list
"
]
[
0
]
unscaled_reg
=
train_noneiv
.
unscaled_reg
unscaled_reg
=
noneiv_conf_dict
[
"
unscaled_reg
"
]
p
=
train_noneiv
.
p
p
=
noneiv_conf_dict
[
"
p
"
]
hidden_layers
=
train_noneiv
.
hidden_layers
hidden_layers
=
noneiv_conf_dict
[
"
hidden_layers
"
]
saved_file
=
os
.
path
.
join
(
'
saved_networks
'
,
saved_file
=
os
.
path
.
join
(
'
saved_networks
'
,
f
'
noneiv_
{
short_dataname
}
'
\
f
'
noneiv_
{
short_dataname
}
'
\
f
'
_init_std_y_
{
init_std_y
:
.
3
f
}
_ureg_
{
unscaled_reg
:
.
1
f
}
'
\
f
'
_init_std_y_
{
init_std_y
:
.
3
f
}
_ureg_
{
unscaled_reg
:
.
1
f
}
'
\
...
@@ -107,11 +123,11 @@ def collect_metrics(x,y, seed=0,
...
@@ -107,11 +123,11 @@ def collect_metrics(x,y, seed=0,
# EiV
# EiV
eiv_metrics
=
{}
eiv_metrics
=
{}
init_std_y
=
train_eiv
.
init_std_y_list
[
0
]
init_std_y
=
eiv_conf_dict
[
"
init_std_y_list
"
]
[
0
]
unscaled_reg
=
train_eiv
.
unscaled_reg
unscaled_reg
=
eiv_conf_dict
[
"
unscaled_reg
"
]
p
=
train_eiv
.
p
p
=
eiv_conf_dict
[
"
p
"
]
hidden_layers
=
train_eiv
.
hidden_layers
hidden_layers
=
eiv_conf_dict
[
"
hidden_layers
"
]
fixed_std_x
=
train_eiv
.
fixed_std_x
fixed_std_x
=
eiv_conf_dict
[
"
fixed_std_x
"
]
saved_file
=
os
.
path
.
join
(
'
saved_networks
'
,
saved_file
=
os
.
path
.
join
(
'
saved_networks
'
,
f
'
eiv_
{
short_dataname
}
'
\
f
'
eiv_
{
short_dataname
}
'
\
f
'
_init_std_y_
{
init_std_y
:
.
3
f
}
_ureg_
{
unscaled_reg
:
.
1
f
}
'
\
f
'
_init_std_y_
{
init_std_y
:
.
3
f
}
_ureg_
{
unscaled_reg
:
.
1
f
}
'
\
...
@@ -180,8 +196,9 @@ for key in collection_keys:
...
@@ -180,8 +196,9 @@ for key in collection_keys:
noneiv_metrics_collection
[
key
]
=
[]
noneiv_metrics_collection
[
key
]
=
[]
eiv_metrics_collection
[
key
]
=
[]
eiv_metrics_collection
[
key
]
=
[]
num_test_epochs
=
10
num_test_epochs
=
10
assert
train_noneiv
.
seed_list
==
train_eiv
.
seed_list
assert
noneiv_conf_dict
[
"
seed_range
"
]
==
eiv_conf_dict
[
"
seed_range
"
]
seed_list
=
train_noneiv
.
seed_list
seed_list
=
range
(
noneiv_conf_dict
[
"
seed_range
"
][
0
],
noneiv_conf_dict
[
"
seed_range
"
][
1
])
max_batch_number
=
2
max_batch_number
=
2
for
seed
in
tqdm
(
seed_list
):
for
seed
in
tqdm
(
seed_list
):
train_data
,
test_data
=
load_data
(
seed
=
seed
)
train_data
,
test_data
=
load_data
(
seed
=
seed
)
...
...
This diff is collapsed.
Click to expand it.
Experiments/train_noneiv.py
+
2
−
0
View file @
e1584c1b
...
@@ -49,6 +49,8 @@ gamma = conf_dict["gamma"]
...
@@ -49,6 +49,8 @@ gamma = conf_dict["gamma"]
hidden_layers
=
conf_dict
[
"
hidden_layers
"
]
hidden_layers
=
conf_dict
[
"
hidden_layers
"
]
seed_range
=
conf_dict
[
'
seed_range
'
]
seed_range
=
conf_dict
[
'
seed_range
'
]
print
(
f
"
Training on
{
long_dataname
}
data
"
)
try
:
try
:
gpu_number
=
conf_dict
[
"
gpu_number
"
]
gpu_number
=
conf_dict
[
"
gpu_number
"
]
device
=
torch
.
device
(
f
'
cuda:
{
gpu_number
}
'
if
torch
.
cuda
.
is_available
()
else
'
cpu
'
)
device
=
torch
.
device
(
f
'
cuda:
{
gpu_number
}
'
if
torch
.
cuda
.
is_available
()
else
'
cpu
'
)
...
...
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