ModErn Text Analysis
META Enumerates Textual Applications
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
include
classify
loss
loss_function_factory.h
Go to the documentation of this file.
1
9
#ifndef META_CLASSIFY_LOSS_FUNCTION_FACTORY_H_
10
#define META_CLASSIFY_LOSS_FUNCTION_FACTORY_H_
11
12
#include <functional>
13
#include <memory>
14
#include <unordered_map>
15
16
#include "
classify/loss/loss_function.h
"
17
#include "
util/factory.h
"
18
#include "
util/shim.h
"
19
20
namespace
meta
21
{
22
namespace
classify
23
{
24
namespace
loss
25
{
26
32
class
loss_function_factory
33
:
public
util::factory
<loss_function_factory, loss_function>
34
{
35
friend
base_factory
;
36
37
private
:
41
loss_function_factory
();
42
46
template
<
class
Loss>
47
void
reg
();
48
};
49
55
std::unique_ptr<loss_function>
56
make_loss_function
(
const
std::string& identifier);
57
62
template
<
class
Loss>
63
std::unique_ptr<loss_function>
make_loss_function
()
64
{
65
return
make_unique<Loss>();
66
}
67
72
template
<
class
Loss>
73
void
register_loss_function
()
74
{
75
loss_function_factory::get
().
add
(Loss::id, make_loss_function<Loss>);
76
}
77
}
78
}
79
}
80
81
#endif
meta::classify::loss::loss_function_factory::loss_function_factory
loss_function_factory()
Constructs the loss_function_factory singleton.
Definition:
loss_function_factory.cpp:22
meta::classify::loss::loss_function_factory
Factory that is responsible for creating loss functions from strings.
Definition:
loss_function_factory.h:32
meta::util::factory::add
void add(const std::string &identifier, Function &&fn)
Associates the given identifier with the given factory method.
Definition:
factory.h:61
meta::classify::loss::loss_function_factory::reg
void reg()
Registers a loss function.
Definition:
loss_function_factory.cpp:17
meta::util::factory
Generic factory that can be subclassed to create factories for specific types.
Definition:
factory.h:27
meta::util::factory< loss_function_factory, loss_function >::get
static loss_function_factory & get()
Obtains the singleton.
Definition:
factory.h:48
meta
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition:
analyzer.h:24
meta::classify::loss::make_loss_function
std::unique_ptr< loss_function > make_loss_function(const std::string &identifier)
Convenience method for making a loss function using the factory.
Definition:
loss_function_factory.cpp:35
factory.h
shim.h
meta::classify::loss::register_loss_function
void register_loss_function()
Registration method for loss functions.
Definition:
loss_function_factory.h:73
loss_function.h
Generated on Tue Mar 3 2015 23:20:16 for ModErn Text Analysis by
1.8.9.1