本文整理汇总了C++中OutputFile::GetFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputFile::GetFileName方法的具体用法?C++ OutputFile::GetFileName怎么用?C++ OutputFile::GetFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputFile
的用法示例。
在下文中一共展示了OutputFile::GetFileName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateCCode
// Write C code for corresponding to the feed forward network into a given file.
void MultipleBackPropagation::GenerateCCode(OutputFile & f, VariablesData & trainVariables, BOOL inputLayerIsConnectedWithOutputLayer, BOOL spaceInputLayerIsConnectedWithOutputLayer) {
CString s;
CString MBPVersion;
MBPVersion.LoadString(IDS_VERSION);
f.WriteLine("/**");
f.WriteLine(_TEXT(" Generated by ") + MBPVersion);
f.WriteLine(" Multiple Back-Propagation can be freely obtained at http://dit.ipg.pt/MBP");
f.WriteLine("*/\n");
f.WriteLine("#include <math.h>");
f.WriteLine("/**");
s.Format(_TEXT(" inputs - should be an array of %d element(s), containing the network input(s)."), inputs);
bool hasMissingValues = false;
for(int i = 0; i < inputs; i++) {
if (trainVariables.HasMissingValues(i)) {
s += " Inputs with NaN value are considered missing values.";
hasMissingValues = true;
break;
}
}
f.WriteLine(s);
s.Format(_TEXT(" outputs - should be an array of %d element(s), that will contain the network output(s)."), outputs);
f.WriteLine(s);
s = " Note : The array inputs will also be changed.";
if (!hasMissingValues) s += "Its values will be rescaled between -1 and 1.";
s += "\n*/";
f.WriteLine(s);
s = f.GetFileName();
int p = s.Find('.');
if (p != -1) s = s.Left(p);
f.WriteLine(_TEXT("void ") + s + _TEXT("(double * inputs, double * outputs) {"));
f.WriteString("\tdouble mainWeights[] = {");
SaveWeights(f, ", ");
f.WriteLine("};");
f.WriteLine("\tdouble * mw = mainWeights;");
if (hasMissingValues) f.WriteLine("\tdouble b;");
if (!spaceNetwork.IsNull()) {
f.WriteString("\tdouble spaceWeights[] = {");
spaceNetwork->SaveWeights(f, ", ");
f.WriteLine("};");
f.WriteLine("\tdouble * sw = spaceWeights;");
s.Format(_TEXT("\tdouble mk[%d];"), spaceNetwork->Outputs());
f.WriteLine(s);
f.WriteLine("\tdouble *m = mk;");
if (hasMissingValues) {
s.Format(L"\tdouble spaceInputs[%d];", inputs);
f.WriteLine(s);
}
}
int numberLayers = layers.Lenght();
for (int l = 1; l < numberLayers - 1; l++) {
s.Format(L"\tdouble hiddenLayer%doutputs[%d];", l, layers.Element(l)->neurons.Lenght());
f.WriteLine(s);
}
int numberSpaceLayers = (spaceNetwork.IsNull()) ? 0 : spaceNetwork->layers.Lenght();
for (int l = 1; l < numberSpaceLayers - 1; l++) {
s.Format(_TEXT("\tdouble spaceHiddenLayer%doutputs[%d];"), l, spaceNetwork->layers.Element(l)->neurons.Lenght());
f.WriteLine(s);
}
f.WriteLine("\tint c;");
f.WriteString("\n");
// input variables will be rescaled between -1 and 1
if (trainVariables.Number() == inputs + outputs) {
for (int i = 0; i < inputs; i++) {
double min = trainVariables.Minimum(i);
double max = trainVariables.Maximum(i);
if (trainVariables.HasMissingValues(i)) {
s.Format(L"\tif(inputs[%d] == inputs[%d]) { /* compiler must have support for NaN numbers */\n\t", i, i);
f.WriteString(s);
}
if (min != max) {
s.Format(L"\tinputs[%d] = -1.0 + (inputs[%d] - %1.15f) / %1.15f;", i, i, min, (max - min)/2);
} else {
s.Format(L"\tinputs[%d] = inputs[%d] / %1.15f; /* WARNING: During the training this variable remain always constant */", i, i, max);
}
f.WriteLine(s);
if (hasMissingValues && !spaceNetwork.IsNull()) {
if (trainVariables.HasMissingValues(i)) f.WriteString("\t");
s.Format(L"\tspaceInputs[%d] = inputs[%d];", i, i);
//.........这里部分代码省略.........