16 #include "neural_parameters_norm.h"
61 from_XML(neural_parameters_norm_document);
121 std::ostringstream buffer;
127 buffer <<
"OpenNN Exception: NeuralParametersNorm class.\n"
128 <<
"void check(void) const method.\n"
129 <<
"Pointer to neural network is NULL.\n";
131 throw std::logic_error(buffer.str());
136 if(!multilayer_perceptron_pointer)
138 buffer <<
"OpenNN Exception: NeuralParametersNorm class.\n"
139 <<
"void check(void) const method.\n"
140 <<
"Pointer to multilayer perceptron is NULL.\n";
142 throw std::logic_error(buffer.str());
148 if(inputs_number == 0)
150 buffer <<
"OpenNN Exception: NeuralParametersNorm class.\n"
151 <<
"void check(void) const method.\n"
152 <<
"Number of inputs in multilayer perceptron object is zero.\n";
154 throw std::logic_error(buffer.str());
157 if(outputs_number == 0)
159 buffer <<
"OpenNN Exception: NeuralParametersNorm class.\n"
160 <<
"void check(void) const method.\n"
161 <<
"Number of outputs in multilayer perceptron object is zero.\n";
163 throw std::logic_error(buffer.str());
186 const double neural_parameters_norm = neural_parameters.
calculate_norm();
266 neural_parameters.resize(neural_parameters_number);
268 const double neural_parameters_norm = neural_parameters.
calculate_norm();
274 const double neural_parameters_norm = parameters.
calculate_norm();
300 neural_parameters.resize(neural_parameters_number);
330 neural_parameters.resize(neural_parameters_number);
369 return(
"NEURAL_PARAMETERS_NORM");
377 std::ostringstream buffer;
381 return(buffer.str());
391 std::ostringstream buffer;
393 tinyxml2::XMLDocument* document =
new tinyxml2::XMLDocument;
397 tinyxml2::XMLElement* neural_network_parameters_norm_element = document->NewElement(
"NeuralParametersNorm");
399 document->InsertFirstChild(neural_network_parameters_norm_element);
403 tinyxml2::XMLElement* weight_element = document->NewElement(
"NeuralParametersNormWeight");
404 neural_network_parameters_norm_element->LinkEndChild(weight_element);
409 tinyxml2::XMLText* weight_text = document->NewText(buffer.str().c_str());
410 weight_element->LinkEndChild(weight_text);
416 tinyxml2::XMLElement* display_element = document->NewElement(
"Display");
417 neural_network_parameters_norm_element->LinkEndChild(display_element);
422 tinyxml2::XMLText* display_text = document->NewText(buffer.str().c_str());
423 display_element->LinkEndChild(display_text);
437 const tinyxml2::XMLElement* root_element = document.FirstChildElement(
"NeuralParametersNorm");
441 std::ostringstream buffer;
443 buffer <<
"OpenNN Exception: NeuralParametersNorm class.\n"
444 <<
"void from_XML(const tinyxml2::XMLDocument&) method.\n"
445 <<
"Neural parameters norm element is NULL.\n";
447 throw std::logic_error(buffer.str());
452 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"NeuralParametersNormWeight");
458 const double new_neural_parameters_norm_weight = atof(element->GetText());
462 catch(
const std::logic_error& e)
464 std::cout << e.what() << std::endl;
471 const tinyxml2::XMLElement* element = root_element->FirstChildElement(
"Display");
477 const std::string new_display_string = element->GetText();
481 catch(
const std::logic_error& e)
483 std::cout << e.what() << std::endl;
bool has_independent_parameters(void) const
std::string write_performance_term_type(void) const
virtual ~NeuralParametersNorm(void)
NeuralParametersNorm(void)
double calculate_performance(void) const
size_t get_inputs_number(void) const
Returns the number of inputs to the multilayer perceptron.
size_t get_outputs_number(void) const
Returns the number of outputs neurons in the multilayer perceptron.
Matrix< T > calculate_norm_Hessian(void) const
Returns the Hessian of the vector norm.
void from_XML(const tinyxml2::XMLDocument &)
Vector< double > calculate_gradient(void) const
std::string write_information(void) const
const double & get_neural_parameters_norm_weight(void) const
Returns the weight value for the neural parameters norm in the performance term expression.
MultilayerPerceptron * get_multilayer_perceptron_pointer(void) const
Returns a pointer to the multilayer perceptron composing this neural network.
double calculate_norm(void) const
Returns the vector norm.
void set_neural_parameters_norm_weight(const double &)
Sets a new weight value for the neural parameters norm in the performance term expression.
tinyxml2::XMLDocument * to_XML(void) const
Returns a representation of the sum squared error object, in XML format.
Vector< double > arrange_parameters(void) const
Returns the values of all the biases and synaptic weights in the multilayer perceptron as a single ve...
Vector< T > calculate_norm_gradient(void) const
Returns the gradient of the vector norm.
double neural_parameters_norm_weight
Weight value for the neural parameters norm regularization term.
Matrix< double > calculate_Hessian(void) const
size_t count_parameters_number(void) const
Returns the number of parameters (biases and synaptic weights) in the multilayer perceptron.