7#ifndef __EXTERNAL_NN_H__
8#define __EXTERNAL_NN_H__
12#include <MedEmbed/MedEmbed/ApplyKeras.h>
29 int set_params(map<string, string>& mapper) {
30 for (
auto &e : mapper)
31 if (e.first ==
"init_file") {
33 if (ak.init_from_text_file(
init_file) < 0)
34 HMTHROW_AND_ERR(
"ERROR: Failed reading layers file %s\n",
init_file.c_str());
35 n_preds = ak.get_output_dimension();
44 int external_nn_learn() {
50 int learn(
const MedFeatures& features) {
return external_nn_learn(); }
52 int Learn(
float *x,
float *y,
int nsamples,
int nftrs) {
return external_nn_learn(); }
53 int Learn(
float *x,
float *y,
const float *w,
int nsamples,
int nftrs) {
return external_nn_learn(); };
67 int Predict(
float *x,
float *&preds,
int nsamples,
int nftrs) { HMTHROW_AND_ERR(
"ExternalNN: Predict(float *,...) not implemented, used the MedMat API instead\n"); };
68 int Predict(
float *x,
float *&preds,
int nsamples,
int nftrs,
int transposed_flag) { HMTHROW_AND_ERR(
"ExternalNN: Predict(float *,...) not implemented, used the MedMat API instead\n"); };
Logger.h - allowing logs with more control.
MedAlgo - APIs to different algorithms: Linear Models, RF, GBM, KNN, and more.
@ MODEL_EXTERNAL_NN
to_use: "external_nn" , initialize a neural net using a layers file. creates MedExternalNN
Definition MedAlgo.h:64
#define ADD_SERIALIZATION_FUNCS(...)
Definition SerializableObject.h:122
#define MEDSERIALIZE_SUPPORT(Type)
Definition SerializableObject.h:108
Definition ApplyKeras.h:82
Definition ExternalNN.h:15
int learn(MedMat< float > &x, MedMat< float > &y, const vector< float > &wgts)
MedMat x,y : will transpose/normalize x,y if needed by algorithm The convention is that untransposed ...
Definition ExternalNN.h:51
int n_preds_per_sample() const
Number of predictions per sample. typically 1 - but some models return several per sample (for exampl...
Definition ExternalNN.h:70
bool predict_single_not_implemented()
Prepartion function for fast prediction on single item each time.
Definition ExternalNN.h:72
int Learn(float *x, float *y, const float *w, int nsamples, int nftrs)
Learn should be implemented for each model.
Definition ExternalNN.h:53
string init_file
Parameters.
Definition ExternalNN.h:22
A class for holding features data as a virtual matrix
Definition MedFeatures.h:47
Base Interface for predictor.
Definition MedAlgo.h:78
MedPredictorTypes classifier_type
The Predicotr enum type.
Definition MedAlgo.h:80