Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lp_nn_robustness_verification
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
ludwig10_masters_thesis
lp_nn_robustness_verification
Commits
706a3ec6
Verified
Commit
706a3ec6
authored
2 years ago
by
Björn Ludwig
Browse files
Options
Downloads
Patches
Plain Diff
refactor(solve_one_instance): rename optimize and include refactor to function
parent
21afadbf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/example_scripts.rst
+1
-1
1 addition, 1 deletion
docs/example_scripts.rst
src/lp_nn_robustness_verification/examples/solve_one_instance.py
+22
-9
22 additions, 9 deletions
...nn_robustness_verification/examples/solve_one_instance.py
with
23 additions
and
10 deletions
docs/example_scripts.rst
+
1
−
1
View file @
706a3ec6
Optimize
Optimize
========
========
.. literalinclude:: examples/
optimiz
e.py
.. literalinclude:: examples/
solve_one_instanc
e.py
Solve chosen instances for several network architectures
Solve chosen instances for several network architectures
========================================================
========================================================
...
...
This diff is collapsed.
Click to expand it.
src/lp_nn_robustness_verification/examples/
optimiz
e.py
→
src/lp_nn_robustness_verification/examples/
solve_one_instanc
e.py
+
22
−
9
View file @
706a3ec6
...
@@ -29,13 +29,15 @@ from lp_nn_robustness_verification.data_types import UncertainArray
...
@@ -29,13 +29,15 @@ from lp_nn_robustness_verification.data_types import UncertainArray
from
lp_nn_robustness_verification.linear_program
import
RobustVerifier
from
lp_nn_robustness_verification.linear_program
import
RobustVerifier
from
lp_nn_robustness_verification.pre_processing
import
LinearInclusion
from
lp_nn_robustness_verification.pre_processing
import
LinearInclusion
if
__name__
==
"
__main__
"
:
SAMPLES_PER_SENSOR
=
10
def
optimize
()
->
None
:
DEPTH
=
1
"""
Solve one specific hard coded instance and time the process
"""
zema_data
=
ZeMASamples
(
size_scaler
=
SAMPLES_PER_SENSOR
,
normalize
=
True
)
samples_per_sensor
=
10
depth
=
1
zema_data
=
ZeMASamples
(
size_scaler
=
samples_per_sensor
,
normalize
=
True
)
nn_params
=
generate_weights_and_biases
(
nn_params
=
generate_weights_and_biases
(
len
(
zema_data
.
values
[
0
]),
len
(
zema_data
.
values
[
0
]),
construct_out_features_counts
(
len
(
zema_data
.
values
[
0
]),
depth
=
DEPTH
),
construct_out_features_counts
(
len
(
zema_data
.
values
[
0
]),
depth
=
depth
),
seed
=
0
,
seed
=
0
,
)
)
for
(
values
,
uncertainties
)
in
zip
(
zema_data
.
values
,
zema_data
.
uncertainties
):
for
(
values
,
uncertainties
)
in
zip
(
zema_data
.
values
,
zema_data
.
uncertainties
):
...
@@ -48,15 +50,26 @@ if __name__ == "__main__":
...
@@ -48,15 +50,26 @@ if __name__ == "__main__":
optimization
=
RobustVerifier
(
linear_inclusion
)
optimization
=
RobustVerifier
(
linear_inclusion
)
optimization
.
solve
()
optimization
.
solve
()
yappi
.
stop
()
yappi
.
stop
()
with
open
(
"
timings.txt
"
,
"
a
"
,
encoding
=
"
utf-8
"
)
as
timings_file
:
with
open
(
(
f
"
{
samples_per_sensor
*
11
}
_inputs_and_
"
f
"
{
depth
}
_layers_with_sample_0_and_seed_0_timings.txt
"
),
"
a
"
,
encoding
=
"
utf-8
"
,
)
as
timings_file
:
timings_file
.
write
(
timings_file
.
write
(
f
"
\n
===================================================================
"
f
"
\n
===================================================================
"
f
"
===================
\n
"
f
"
===================
\n
"
f
"
Timings for
{
SAMPLES_PER_SENSOR
*
11
}
inputs and
{
DEPTH
}
"
f
"
Timings for
{
samples_per_sensor
*
11
}
inputs and
"
f
"
{
'
layers
'
if
DEPTH
>
1
else
'
layer
'
}
"
f
"
{
depth
}
{
'
layers
'
if
depth
>
1
else
'
layer
'
}
with sample 0 and seed 0
"
f
"
\n
===================================================================
"
f
"
\n
===================================================================
"
f
"
===================
\n
"
f
"
===================
\n
"
)
)
yappi
.
get_func_stats
().
print_all
(
yappi
.
get_func_stats
().
print_all
(
# type: ignore[import]
out
=
timings_file
,
columns
=
{
0
:
(
"
name
"
,
180
),
3
:
(
"
ttot
"
,
8
)}
out
=
timings_file
,
columns
=
{
0
:
(
"
name
"
,
180
),
3
:
(
"
ttot
"
,
8
)}
)
)
if
__name__
==
"
__main__
"
:
optimize
()
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