本文整理汇总了C++中Network::Train方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::Train方法的具体用法?C++ Network::Train怎么用?C++ Network::Train使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::Train方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{ Network my;
unsigned long inp=2;
unsigned long hid=2;
unsigned long outp=1;
unsigned long layers[3];
layers[0]=inp;
layers[1]=hid;
layers[2]=outp;
int i=0,j=0;
unsigned long iter=0;
cout<<"Enter number of training Iterations : ";
cin>>iter;
my.SetData(0.1,layers,3);
double input[]={1,0};
double *outputs;
my.RandomizeWB();
double tr_inp[4][2]={{0.0,0.0},{1.0,0.0},{0.0,1.0},{1.0,1.0}};
double tr_out[4][1]={{0.0},{1.0},{1.0},{0.0}};
cout<<"\nStarting Training... ";
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
for(i=0;i<iter;i++){
//cout<<"\nTraining : "<<i+1;
for(j=0;j<4;j++){
my.Train(tr_inp[j],tr_out[j]);
}}
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;
std::time_t end_time = std::chrono::system_clock::to_time_t(end);
std::cout << "finished computation at " << std::ctime(&end_time)<< "elapsed time: " << elapsed_seconds.count() << "s\n";
cout<<"\nEnding Training. ";
cout<<"\n\nStarting Testing... \n";
for(j=0;j<4;j++){
cout<<"\n\nCase number : "<<j+1;
my.SetInputs(tr_inp[j]);
outputs=my.GetOutput();
for(i=0;i<inp;i++){
cout<<"\nInput"<<i+1<<" : "<<tr_inp[j][i];
}
for(i=0;i<outp;i++){
cout<<"\nOutput"<<i+1<<" : "<<outputs[i];
}
delete outputs;
double *outputs;
}
cout<<"\n\nEnd Testing.\n\n";
//cin.get();
//system("PAUSE");
return 0;
}