Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.activation
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
Model registry
Operate
Environments
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
bob
bob.learn.activation
Commits
b0ef4f74
Commit
b0ef4f74
authored
5 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Pushed some fixes in the method
parent
6404e6c7
Branches
Branches containing commit
No related tags found
1 merge request
!6
WIP: First attempt to approach the issue bob.bio.base#106
Pipeline
#32445
passed
5 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/activation/activation.py
+9
-8
9 additions, 8 deletions
bob/learn/activation/activation.py
bob/learn/activation/test.py
+13
-0
13 additions, 0 deletions
bob/learn/activation/test.py
with
22 additions
and
8 deletions
bob/learn/activation/activation.py
+
9
−
8
View file @
b0ef4f74
...
...
@@ -19,11 +19,12 @@ class Activation(_Activation_C):
"""
return
{
"
id
"
:
self
.
unique_identifier
()}
def
from_dict
(
input_dict
):
@classmethod
def
from_dict
(
cls
,
input_dict
):
"""
Loads itself from a python dict :py:class:`dict`
"""
pass
return
cls
()
class
Logistic
(
_Logistic_C
,
Activation
):
...
...
@@ -42,15 +43,15 @@ class Linear(_Linear_C, Activation):
def
to_dict
(
self
):
return
{
"
id
"
:
self
.
unique_identifier
(),
"
C
"
:
self
.
C
}
@
static
method
def
from_dict
(
input_dict
):
@
class
method
def
from_dict
(
cls
,
input_dict
):
"""
Loads itself from a python dict :py:class:`dict`
"""
if
"
C
"
in
input_dict
:
C
=
float
(
input_dict
[
"
C
"
])
return
Linear
(
C
=
C
)
return
cls
(
C
=
C
)
else
:
raise
ValueError
(
"
Missing parameter `C` in `input_dict`
"
)
...
...
@@ -59,8 +60,8 @@ class MultipliedHyperbolicTangent(_MultipliedHyperbolicTangent_C, Activation):
def
to_dict
(
self
):
return
{
"
id
"
:
self
.
unique_identifier
(),
"
C
"
:
self
.
C
,
"
M
"
:
self
.
M
}
@
static
method
def
from_dict
(
input_dict
):
@
class
method
def
from_dict
(
cls
,
input_dict
):
"""
Loads itself from a python dict :py:class:`dict`
"""
...
...
@@ -75,4 +76,4 @@ class MultipliedHyperbolicTangent(_MultipliedHyperbolicTangent_C, Activation):
else
:
raise
ValueError
(
"
Missing parameter `M` in `input_dict`
"
)
return
MultipliedHyperbolicTangent
(
C
=
C
,
M
=
M
)
return
cls
(
C
=
C
,
M
=
M
)
This diff is collapsed.
Click to expand it.
bob/learn/activation/test.py
+
13
−
0
View file @
b0ef4f74
...
...
@@ -409,6 +409,19 @@ def test_to_dict():
def
test_from_dict
():
# The first 3 tests don't make much sense, but I'm testing them anyways
input_dict
=
{
"
id
"
:
"
bob.learn.activation.Activation.Logistic
"
}
logistic
=
Logistic
.
from_dict
(
input_dict
)
assert
isinstance
(
logistic
,
Logistic
)
input_dict
=
{
"
id
"
:
"
bob.learn.activation.Activation.HyperbolicTangent
"
}
hyperbolic_tangent
=
HyperbolicTangent
.
from_dict
(
input_dict
)
assert
isinstance
(
hyperbolic_tangent
,
HyperbolicTangent
)
input_dict
=
{
"
id
"
:
"
bob.learn.activation.Activation.Identity
"
}
identity
=
Identity
.
from_dict
(
input_dict
)
assert
isinstance
(
identity
,
Identity
)
input_dict
=
{
"
id
"
:
"
bob.learn.activation.Activation.Linear
"
,
"
C
"
:
2.0
}
linear
=
Linear
.
from_dict
(
input_dict
)
assert
linear
.
C
==
2
...
...
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