-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.h
49 lines (35 loc) · 1.61 KB
/
functions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include <Eigen>
//从文件读入训练数据
void readTrainData(std::string filePath, Eigen::MatrixXf &featuresMat,
Eigen::MatrixXf &targetsMat,
std::vector<std::string> &id_label_list);
//从文件读入测试数据
void readValData(std::string filePath,
std::vector<std::string> id_label_list,
Eigen::MatrixXf &featuresMat,
Eigen::MatrixXf &targetsMat);
//从文件读入特征
void readFeature(std::string filePath, Eigen::MatrixXf &featuresMat);
//求广义逆
Eigen::MatrixXf pinv(Eigen::MatrixXf A);
//生成随机矩阵
void genRandomMat(Eigen::MatrixXf &mat, int rows, int cols,
float lowerLimit, float upperLimit, int randomState);
//sigmoid激活函数
void sigmoid(Eigen::MatrixXf &mat);
//找到一行中的最大值id
int getRowMaxId(Eigen::MatrixXf row);
//根据输出向量和target向量计分
float calcScore(const Eigen::MatrixXf &output, const Eigen::MatrixXf &target);
//保存、读取string键值与输出向量的对应关系
void saveLabelList(std::string filePath, std::vector<std::string> id_label_list);
void loadLabelList(std::string filePath, std::vector<std::string> &id_label_list);
//特征归一化
void normFeatures(Eigen::MatrixXf &featuresMat, float lowerLimit, float upperLimit);
//elm输出的dense编码
void denseEncodeOutput(const Eigen::MatrixXf &mat, Eigen::MatrixXf &result);
//投票法(输入是多个elm输出的dense code)
void elmsVote(const Eigen::MatrixXf &input, int outDim, Eigen::MatrixXf &output);
#endif // FUNCTIONS_H