bktrain.cpp

来自「類神經網路的BK演算法」· C++ 代码 · 共 48 行

CPP
48
字号
#include <stdio.h>

#include <stdlib.h>

#include "bkneuro.h"

//void main()

main()

{

// Declaration

  char filename[128];

  int i,key,nb_cycle;

  float err;

  BKNeuroNet nn;

// I/O interface

  cout<<"Input filename of training data : ";

  cin>>filename;

  ifstream in(filename);

  ofstream out1("learncur.dat");

  ofstream out2("neurowgt.dat");

  if(!in){cout<<"Cannot open file! Any key to terminate...";

  getchar();exit(1);}



// Loading the dataset and initialization of network

  nn.LoadTrainingData(in);



// Training

  while(1)

  {

	cout<<"Input the numeber of cycles:"<<endl;

	cin>>nb_cycle;

  	for(i=0;i<nb_cycle;i++)

  	{

		err=nn.LearningFromBatchData();

		out1<<i<<" : \t"<<err<<endl;

	}

	cout<<"error : "<<err<<endl;

	cout<<"encore? (1/0) ";cin>>key;if(key==0)break;

  }



// Save the connection weights of network

  nn.Save(out2);



// The end

  cout<<endl<<"The convergence curve is saved in learncur.dat"<<endl;

  cout<<"any key to terminate...";

   getchar();

}





⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?