FCNN.cpp
// builds network based on the command-line parameters it's given (see also Usage())

builds network based on the command-line parameters it's given )
builds network based on the command - line parameters it ' s given )
bool BuildNetwork(NeuralNetwork & nn, std::list<string>& params) {
	cout << "----------NETWORK----------\n";
	unsigned layerno = 1;
	bool has_terminal_layer = false;
	while ((params.size() > 0) && (IsInteger(params.front()))) {
		int layersize = atoi(params.front().c_str()); 
		params.pop_front();
		cout << "layer #" << layerno << " size " << layersize << " ";
		if ((layerno == 1) && (layersize != INPUT_LAYER_SIZE)) {
			cerr << "  first layer input size has to match input dimension (" << INPUT_LAYER_SIZE << ")" << endl;
			return false;
		}
		if (params.empty()) {
			cerr << "  no activation function for layer #" << layerno << " (size: " << layersize << ")" << endl;
			return false;
		}
		string actfnname = params.front(); 
		params.pop_front();
		auto it = global_actFns.find(actfnname);
		if (it == global_actFns.end()) {
			cerr << "  unknown activation function: " << actfnname << endl;
			return false;
		}
		cout << "act.fn. " << it->first << endl;
		auto activationFunction = it->second.first;
		auto activationFnDerived = it->second.second;
		nn << std::make_unique<NNFullyConnected>(layersize);
		nn << std::make_unique<NNNonLinearity>(activationFunction, activationFnDerived);
		if (params.size() > 0) {
			auto it2 = global_errFns.find(params.front());
			if (it2 != global_errFns.end()) {
				params.pop_front(); 
				cout << "errfn. " << it2->first << endl;
				nn << std::make_unique<NNTerminal>(TERMINAL_LAYER_SIZE, it2->second.first, it2->second.second);
				has_terminal_layer = true;
				break;
			}
		}
		++layerno;
	}
	if (!has_terminal_layer) {
		cout << "  no error function given, using default (MSE)" << endl;
		nn << std::make_unique<NNTerminal>(TERMINAL_LAYER_SIZE, squared_err, squared_err_d);
	}
	nn.LinkLayerAll();
	return true;
}
bool BuildNetwork ( NeuralNetwork & nn , std :: list < string > & params ) { cout << " \n " ; unsigned layerno = 1 ; bool has_terminal_layer = false ; while ( ( params . size ( ) > 0 ) && ( IsInteger ( params . front ( ) ) ) ) { int layersize = atoi ( params . front ( ) . c_str ( ) ) ; params . pop_front ( ) ; cout << " " << layerno << " " << layersize << " " ; if ( ( layerno == 1 ) && ( layersize != INPUT_LAYER_SIZE ) ) { cerr << " " << INPUT_LAYER_SIZE << " " << endl ; return false ; } if ( params . empty ( ) ) { cerr << " " << layerno << " " << layersize << " " << endl ; return false ; } string actfnname = params . front ( ) ; params . pop_front ( ) ; auto it = global_actFns . find ( actfnname ) ; if ( it == global_actFns . end ( ) ) { cerr << " " << actfnname << endl ; return false ; } cout << " " << it -> first << endl ; auto activationFunction = it -> second . first ; auto activationFnDerived = it -> second . second ; nn << std :: make_unique < NNFullyConnected > ( layersize ) ; nn << std :: make_unique < NNNonLinearity > ( activationFunction , activationFnDerived ) ; if ( params . size ( ) > 0 ) { auto it2 = global_errFns . find ( params . front ( ) ) ; if ( it2 != global_errFns . end ( ) ) { params . pop_front ( ) ; cout << " " << it2 -> first << endl ; nn << std :: make_unique < NNTerminal > ( TERMINAL_LAYER_SIZE , it2 -> second . first , it2 -> second . second ) ; has_terminal_layer = true ; break ; } } ++ layerno ; } if ( ! has_terminal_layer ) { cout << " " << endl ; nn << std :: make_unique < NNTerminal > ( TERMINAL_LAYER_SIZE , squared_err , squared_err_d ) ; } nn . LinkLayerAll ( ) ; return true ; }
builds network based on the command-line parameters it's given (see also Usage())
builds network based on the command - line parameters it ' s given ( see also Usage () )
// check if next argument is an error function
 // then this will be treated as the last argument -- pop only if this is the case
