Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FreeForestML
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CERN
fsauerbu
FreeForestML
Merge requests
!10
WIP: Resolve "Toy dataset"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
WIP: Resolve "Toy dataset"
7-toy-dataset
into
master
Overview
1
Commits
8
Pipelines
1
Changes
2
Closed
Frank Sauerburger
requested to merge
7-toy-dataset
into
master
5 years ago
Overview
1
Commits
8
Pipelines
1
Changes
2
Expand
Closes
#7 (closed)
0
0
Merge request reports
Viewing commit
3e4f3137
Prev
Next
Show latest version
2 files
+
115
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
Unverified
3e4f3137
Implement PDFs
· 3e4f3137
Frank Sauerburger
authored
5 years ago
nnfwtbn/tests/test_toydata.py
+
79
−
1
Options
import
unittest
import
numpy
as
np
from
nnfwtbn.toydata
import
rand
from
nnfwtbn.toydata
import
rand
,
ipdf_gluon
,
ipdf_quark
class
ToyDataTestBase
(
unittest
.
TestCase
):
@@ -51,3 +51,81 @@ class ToyDataTestBase(unittest.TestCase):
self
.
assertAlmostEqual
(
a
,
0.90141859
)
self
.
assertAlmostEqual
(
b
,
0.85225178
)
self
.
assertAlmostEqual
(
c
,
0.93632300
)
def
test_pdf_gluon_pos
(
self
):
"""
Check that the pdf is always positive.
"""
N
=
100
for
i
in
range
(
N
):
self
.
assertTrue
(
ipdf_gluon
(
i
/
N
,
1
/
N
)
>=
0
)
def
test_pdf_gluon_normalized
(
self
):
"""
Check that the pdf is normalized.
"""
self
.
assertAlmostEqual
(
ipdf_gluon
(
0
,
1
),
1
)
def
test_pdf_gluon_max
(
self
):
"""
Check that the pdf has it
'
s maximum at x=0.
"""
N
=
100
bins
=
np
.
empty
(
N
)
for
i
in
range
(
N
):
bins
[
i
]
=
ipdf_gluon
(
i
/
N
,
1
/
N
)
self
.
assertEqual
(
np
.
argmax
(
bins
),
0
)
def
test_pdf_gluon_at_1
(
self
):
"""
Check that the pdf vanishes at x=1.
"""
d
=
1e-4
self
.
assertAlmostEqual
(
ipdf_gluon
(
1
-
d
,
d
),
0
)
def
test_pdf_quark_pos
(
self
):
"""
Check that the pdf is always positive.
"""
N
=
100
for
i
in
range
(
N
):
self
.
assertTrue
(
ipdf_quark
(
i
/
N
,
1
/
N
)
>=
0
)
def
test_pdf_quark_normalized
(
self
):
"""
Check that the pdf is normalized.
"""
self
.
assertAlmostEqual
(
ipdf_quark
(
0
,
1
),
1
)
def
test_pdf_quark_max
(
self
):
"""
Check that the pdf has it
'
s maximum at x=0.
"""
N
=
100
bins
=
np
.
empty
(
N
)
for
i
in
range
(
N
):
bins
[
i
]
=
ipdf_quark
(
i
/
N
,
1
/
N
)
self
.
assertEqual
(
np
.
argmax
(
bins
),
0
)
def
test_pdf_quark_at_1
(
self
):
"""
Check that the pdf vanishes at x=1.
"""
d
=
1e-9
self
.
assertAlmostEqual
(
ipdf_quark
(
1
-
d
,
d
),
0
)
def
test_pdf_quark_peak
(
self
):
"""
Check that there is a peak at x=0.5.
"""
d
=
1e-4
self
.
assertGreater
(
ipdf_quark
(
0.5
,
d
),
ipdf_quark
(
0.3
,
d
)
)
Loading