17 #include "inverse_sum_squared_error.h"
62 :
PerformanceTerm(new_neural_network_pointer, new_mathematical_model_pointer, new_data_set_pointer)
118 return(
"LookUpTable");
122 case IndependentParametersValues:
124 return(
"IndependentParametersValues");
130 std::ostringstream buffer;
132 buffer <<
"OpenNN Exception: InverseSumSquaredError class.\n"
133 <<
"std::string write_unknowns_method(void) const method.\n"
134 <<
"Unknown property method.\n";
136 throw std::logic_error(buffer.str());
161 if(new_unknowns_method ==
"LookUpTable")
165 else if(new_unknowns_method ==
"IndependentParametersValues")
171 std::ostringstream buffer;
173 buffer <<
"OpenNN Exception: ScalingLayer class.\n"
174 <<
"void set_unknowns_method(const std::string&) method.\n"
175 <<
"Unknown property method: " << new_unknowns_method <<
".\n";
177 throw std::logic_error(buffer.str());
205 std::ostringstream buffer;
211 buffer <<
"OpenNN Exception: InverseSumSquaredError class.\n"
212 <<
"void check(void) const method.\n"
213 <<
"Pointer to neural network is NULL.\n";
215 throw std::logic_error(buffer.str());
220 if(!multilayer_perceptron_pointer)
222 buffer <<
"OpenNN Exception: InverseSumSquaredError class.\n"
223 <<
"void check(void) const method.\n"
224 <<
"Pointer to multilayer perceptron is NULL.\n";
226 throw std::logic_error(buffer.str());
232 if(inputs_number == 0)
234 buffer <<
"OpenNN Exception: InverseSumSquaredError class.\n"
235 <<
"void check(void) const method.\n"
236 <<
"Number of inputs in multilayer perceptron object is zero.\n";
238 throw std::logic_error(buffer.str());
241 if(outputs_number == 0)
243 buffer <<
"OpenNN Exception: InverseSumSquaredError class.\n"
244 <<
"void check(void) const method.\n"
245 <<
"Number of outputs in multilayer perceptron object is zero.\n";
247 throw std::logic_error(buffer.str());
254 buffer <<
"OpenNN Exception: InverseSumSquaredError class.\n"
255 <<
"void check(void) const method.\n"
256 <<
"Pointer to mathematical model is NULL.\n";
258 throw std::logic_error(buffer.str());
265 buffer <<
"OpenNN Exception: InverseSumSquaredError class.\n"
266 <<
"void check(void) const method.\n"
267 <<
"Pointer to data set is NULL.\n";
269 throw std::logic_error(buffer.str());
296 const size_t training_instances_number = training_input_data.
get_rows_number();
320 const size_t size = potential_parameters.size();
324 if(size != parameters_number)
326 std::ostringstream buffer;
328 buffer <<
"OpenNN Exception: InverseSumSquaredError class.\n"
329 <<
"double calculate_performance(const Vector<double>&) const method.\n"
330 <<
"Size (" << size <<
") must be equal to number of parameters (" << parameters_number <<
").\n";
332 throw std::logic_error(buffer.str());
378 size_t generalization_index;
393 double generalization_objective = 0.0;
397 #pragma omp parallel for private(i, generalization_index, inputs, outputs, targets) reduction(+ : generalization_objective)
399 for(i = 0; i < (int)generalization_instances_number; i++)
401 generalization_index = generalization_indices[i];
425 return(generalization_objective);
435 return(
"INVERSE_SUM_SQUARED_ERROR");
446 std::ostringstream buffer;
448 tinyxml2::XMLDocument* document =
new tinyxml2::XMLDocument;
452 tinyxml2::XMLElement* inverse_sum_squared_error_element = document->NewElement(
"InverseSumSquaredError");
454 document->InsertFirstChild(inverse_sum_squared_error_element);
461 inverse_sum_squared_error_element->LinkEndChild(element);
466 tinyxml2::XMLElement* element = document->NewElement(
"UnknownsMethod");
467 inverse_sum_squared_error_element->LinkEndChild(element);
470 element->LinkEndChild(text);
476 tinyxml2::XMLElement* display_element = document->NewElement(
"Display");
477 inverse_sum_squared_error_element->LinkEndChild(display_element);
482 tinyxml2::XMLText* display_text = document->NewText(buffer.str().c_str());
483 display_element->LinkEndChild(display_text);
size_t count_parameters_number(void) const
Matrix< double > arrange_training_input_data(void) const
UnknownsMethod
Enumeration of the different methods for putting the unknowns into the mathematical model...
const Variables & get_variables(void) const
Returns a constant reference to the variables object composing this data set object.
double calculate_sum_squared_error(const Matrix< double > &) const
size_t get_inputs_number(void) const
Returns the number of inputs to the multilayer perceptron.
bool has_missing_values(void) const
InverseSumSquaredError(void)
tinyxml2::XMLDocument * to_XML(void) const
size_t get_outputs_number(void) const
Returns the number of outputs neurons in the multilayer perceptron.
Vector< double > calculate_outputs(const Vector< double > &) const
const MissingValues & get_missing_values(void) const
Returns a reference to the missing values object in the data set.
double calculate_performance(void) const
void set_unknowns_method(const UnknownsMethod &)
Vector< size_t > arrange_targets_indices(void) const
Returns the indices of the target variables.
size_t count_generalization_instances_number(void) const
Returns the number of instances in the data set which will be used for generalization.
Vector< double > get_instance(const size_t &) const
void from_XML(const tinyxml2::XMLDocument &)
MultilayerPerceptron * get_multilayer_perceptron_pointer(void) const
Returns a pointer to the multilayer perceptron composing this neural network.
double calculate_sum_squared_error(const Vector< double > &) const
std::string write_performance_term_type(void) const
Returns a string with the name of the inverser sum squared error performance type, "INVERSE_SUM_SQUARED_ERROR".
const size_t & get_rows_number(void) const
Returns the number of rows in the matrix.
std::string write_unknowns_method(void) const
This returns a string with the name of the method for entering the unknown values or functions into t...
virtual ~InverseSumSquaredError(void)
virtual Matrix< double > calculate_dependent_variables(const NeuralNetwork &, const Matrix< double > &) const
Matrix< double > arrange_training_target_data(void) const
const UnknownsMethod & get_unknowns_method(void) const
This returns the method for entering the unknown values or functions into the mathematical model...
UnknownsMethod unknowns_method
Variable containing the method for putting the unknowns into the mathematical model.
double calculate_generalization_performance(void) const
tinyxml2::XMLDocument * to_XML(void) const
Serializes this numerical differentiation object into a XML document->
Vector< size_t > arrange_generalization_indices(void) const
Returns the indices of the instances which will be used for generalization.
void set_parameters(const Vector< double > &)
Vector< size_t > arrange_inputs_indices(void) const
Returns the indices of the input variables.
const Instances & get_instances(void) const
Returns a constant reference to the instances object composing this data set object.