Skip to content
Snippets Groups Projects
Commit 653163bb authored by Manuel Günther's avatar Manuel Günther
Browse files

Added implementations of missing functions.

parent 88c3bf2f
Branches
Tags
No related merge requests found
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment