Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tayloranalysis
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
Lars Sowa
tayloranalysis
Commits
dae3f6b0
Commit
dae3f6b0
authored
6 months ago
by
Lars Sowa
Browse files
Options
Downloads
Patches
Plain Diff
add test for mutliprocessing
parent
b7d4b8e5
Branches
Branches containing commit
No related tags found
1 merge request
!10
Multiprocessing
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_tc_computation.py
+25
-5
25 additions, 5 deletions
tests/test_tc_computation.py
with
25 additions
and
5 deletions
tests/test_tc_computation.py
+
25
−
5
View file @
dae3f6b0
import
torch
import
unittest
from
src.tayloranalysis
import
extend_model
from
src.tayloranalysis
import
extend_model
,
BaseTaylorAnalysis
class
Polynom
(
torch
.
nn
.
Module
):
class
Polynom
(
torch
.
nn
.
Module
,
BaseTaylorAnalysis
):
def
__init__
(
self
):
torch
.
nn
.
Module
.
__init__
(
self
)
...
...
@@ -14,7 +14,7 @@ class Polynom(torch.nn.Module):
return
x
*
y
+
x
*
y
**
2
+
y
**
3
class
FlippedPolynom
(
torch
.
nn
.
Module
):
class
FlippedPolynom
(
torch
.
nn
.
Module
,
BaseTaylorAnalysis
):
def
__init__
(
self
):
torch
.
nn
.
Module
.
__init__
(
self
)
...
...
@@ -28,8 +28,8 @@ class TestTCComputation(unittest.TestCase):
def
setUp
(
self
):
# setup models
self
.
models
=
[
extend_model
(
Polynom
)
(),
extend_model
(
FlippedPolynom
)
(),
Polynom
(),
FlippedPolynom
(),
]
self
.
feature_axis
=
(
-
1
,
-
2
)
...
...
@@ -75,6 +75,26 @@ class TestTCComputation(unittest.TestCase):
# compare result to expected value
self
.
assertAlmostEqual
(
tc
,
self
.
solution_dict
[
combination
])
def
test_coefficients_multiprocessing
(
self
):
for
combination
in
self
.
solution_dict
.
keys
():
for
_model
,
_feature_axis
,
_point
in
zip
(
self
.
models
,
self
.
feature_axis
,
self
.
points
,
):
# compute TC
tc
=
_model
.
get_tc
(
"
point
"
,
forward_kwargs
=
{
"
point
"
:
_point
},
tc_idx_list
=
[
combination
],
tctensor_features_axis
=
_feature_axis
,
use_parallelization
=
3
,
)
tc
=
tc
[
combination
].
item
()
# as float
with
self
.
subTest
(
combination
=
combination
,
feature_axis
=
_feature_axis
):
# compare result to expected value
self
.
assertAlmostEqual
(
tc
,
self
.
solution_dict
[
combination
])
if
__name__
==
"
__main__
"
:
# run TestTCComputation
...
...
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