14 namespace PhysicsTools {
18 static std::vector<std::string>
split(
const std::string
line,
char delim)
20 const char *str = line.c_str();
23 std::vector<std::string>
tokens;
29 const char *
q = std::strchr(p, delim);
32 tokens.push_back(std::string(p));
35 tokens.push_back(std::string(p, q - p));
43 MLP::MLP(
unsigned int nIn,
unsigned int nOut,
const std::string layout_) :
44 initialized(
false), layers(0), layout(0), epoch(0)
48 <<
"mlpfit doesn't support more than one instance."
51 std::vector<std::string> parsed =
split(layout_,
':');
52 if (parsed.size() < 1)
54 <<
"Invalid layout." << std::endl;
56 layout =
new int[parsed.size() + 2];
61 std::istringstream ss(parsed[
i]);
66 <<
"Invalid layout." << std::endl;
70 layout[layers + 1] = (int)nOut;
116 PAT.Npat[0] = (int)size;
134 std::memcpy(&
PAT.vRin[0][row*(nIn + 1) + 1], data,
sizeof(
double) * nIn);
135 std::memcpy(&
PAT.Rans[0][row][0], target,
sizeof(
double) * nOut);
158 <<
"Error opening \"" << file <<
"\"." << std::endl;
164 if (
LoadWeights(const_cast<char*>(file.c_str()), &epoch_) < 0)
166 <<
"Error opening \"" << file <<
"\"." << std::endl;
167 epoch = (
unsigned int)epoch_;
dbl MLP_Epoch(int iepoch, dbl *alpmin, int *Ntest)
int SaveWeights(char *filename, int iepoch)
int MLP_SetNet(int *nl, int *nn)
void MLP_Out_T(type_pat *rrin)
int LoadWeights(char *filename, int *iepoch)
int AllocPatterns(int ifile, int npat, int nin, int nout, int iadd)
int FreePatterns(int ifile)
tuple size
Write out results.