Model¶
-
enum
elsa::ml
::
MlBackend
¶ Backend to execute model primitives.
Values:
-
enumerator
Auto
¶ Automatically choose the fastest backend available.
-
enumerator
Dnnl
¶ Use the Dnnl, aka. OneDNN backend which is optimized for CPUs.
-
enumerator
Cudnn
¶ Use the Cudnn backend which is optimized for Nvidia GPUs.
-
enumerator
-
template<typename
data_t
= real_t, MlBackendBackend
= MlBackend::Auto>
classelsa::ml
::
Model
¶ A ml model that can be used for training and inference.
- Author
David Tellenbach
- Template Parameters
data_t
: The type of all coefficients used in the model. This parameter is optional and defaults to real_t.Backend
: The MlBackend that will be used for inference and training. This parameter is optional and defaults to MlBackend::Auto.
Public Functions
-
Model
() = default¶ Default constructor.
-
Model
(std::initializer_list<Input<data_t>*> inputs, std::initializer_list<Layer<data_t>*> outputs, const std::string &name = "model")¶ Construct a model by specifying a set of in- and outputs.
- Parameters
inputs
: a list if input layersoutputs
: a list of layers that serve as this model’s outputsname
: a name for this model
-
Model
(Input<data_t> *input, Layer<data_t> *output, const std::string &name = "model")¶ Construct a model by specifying a single input and a single output
- Parameters
input
: an input layeroutput
: a layer that serves as this model’s outputname
: a name for this model
-
void
compile
(const Loss<data_t> &loss, Optimizer<data_t> *optimizer)¶ Compile the model by specifying a loss function and an optimizer.
-
index_t
getBatchSize
() const¶ Get this model’s batch-size.
-
std::string
getName
() const¶ Get this models name.
-
History
fit
(const std::vector<DataContainer<data_t>> &x, const std::vector<DataContainer<data_t>> &y, index_t epochs)¶ Train the model by providing inputs x and labels y.
- Return
a Model::History object
- Parameters
x
: model inputy
: labelsepochs
: training epochs
-
DataContainer<data_t>
predict
(const DataContainer<data_t> &x)¶ Perform inference for a given input x.
Friends
-
struct
History
¶