Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.learn.activation
Commits
653163bb
Commit
653163bb
authored
Aug 19, 2014
by
Manuel Günther
Browse files
Added implementations of missing functions.
parent
88c3bf2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/learn/activation/cpp/ActivationRegistry.cpp
View file @
653163bb
...
...
@@ -8,12 +8,35 @@
*/
#include <bob.learn.activation/Activation.h>
#include <boost/make_shared.hpp>
boost
::
shared_ptr
<
bob
::
learn
::
activation
::
ActivationRegistry
>
bob
::
learn
::
activation
::
ActivationRegistry
::
instance
()
{
static
boost
::
shared_ptr
<
bob
::
learn
::
activation
::
ActivationRegistry
>
s_instance
(
new
ActivationRegistry
());
return
s_instance
;
}
boost
::
shared_ptr
<
bob
::
learn
::
activation
::
Activation
>
bob
::
learn
::
activation
::
load_activation
(
bob
::
io
::
base
::
HDF5File
&
f
)
{
auto
make
=
ActivationRegistry
::
instance
()
->
find
(
f
.
read
<
std
::
string
>
(
"id"
));
return
make
(
f
);
}
boost
::
shared_ptr
<
bob
::
learn
::
activation
::
Activation
>
bob
::
learn
::
activation
::
make_deprecated_activation
(
uint32_t
e
)
{
switch
(
e
)
{
case
0
:
return
boost
::
make_shared
<
bob
::
learn
::
activation
::
IdentityActivation
>
();
break
;
case
1
:
return
boost
::
make_shared
<
bob
::
learn
::
activation
::
HyperbolicTangentActivation
>
();
break
;
case
2
:
return
boost
::
make_shared
<
bob
::
learn
::
activation
::
LogisticActivation
>
();
break
;
default:
throw
std
::
runtime_error
(
"unsupported (deprecated) activation read from HDF5 file - not any of 0 (linear), 1 (tanh) or 2 (logistic)"
);
}
}
void
bob
::
learn
::
activation
::
ActivationRegistry
::
deregisterFactory
(
const
std
::
string
&
id
)
{
s_id2factory
.
erase
(
id
);
}
...
...
@@ -35,7 +58,6 @@ void bob::learn::activation::ActivationRegistry::registerActivation(const std::s
//replacing with the same factory may be the result of multiple python
//modules being loaded.
}
}
bool
bob
::
learn
::
activation
::
ActivationRegistry
::
isRegistered
(
const
std
::
string
&
id
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment