1 // OpenNN: Open Neural Networks Library 2 // www.opennn.net 3 // 4 // M I N K O W S K I E R R O R C L A S S H E A D E R 5 // 6 // Artificial Intelligence Techniques SL 7 // artelnics@artelnics.com 8 9 #ifndef MINKOWSKIERROR_H 10 #define MINKOWSKIERROR_H 11 12 // System includes 13 14 #include <string> 15 #include <sstream> 16 #include <iostream> 17 #include <fstream> 18 #include <cmath> 19 20 // OpenNN includes 21 22 #include "config.h" 23 #include "loss_index.h" 24 #include "data_set.h" 25 26 namespace OpenNN 27 { 28 29 /// This class represents the Minkowski error term. 30 31 /// 32 /// The Minkowski error measures the difference between the outputs of a neural network and the targets in a data set. 33 /// This error term is used in data modeling problems. 34 /// It can be more useful when the data set presents outliers. 35 36 class MinkowskiError : public LossIndex 37 { 38 39 public: 40 41 // Constructors 42 43 explicit MinkowskiError(); 44 45 explicit MinkowskiError(NeuralNetwork*, DataSet*); 46 47 // Destructor 48 49 virtual ~MinkowskiError(); 50 51 // Get methods 52 53 type get_Minkowski_parameter() const; 54 55 // Set methods 56 57 void set_default(); 58 59 void set_Minkowski_parameter(const type&); 60 61 // loss methods 62 63 void calculate_error(const DataSet::Batch& batch, 64 const NeuralNetwork::ForwardPropagation& forward_propagation, 65 LossIndex::BackPropagation& back_propagation) const; 66 67 void calculate_output_gradient(const DataSet::Batch& batch, 68 const NeuralNetwork::ForwardPropagation& forward_propagation, 69 BackPropagation& back_propagation) const; 70 71 // Serialization methods 72 73 string get_error_type() const; 74 string get_error_type_text() const; 75 76 77 void from_XML(const tinyxml2::XMLDocument&); 78 79 void write_XML(tinyxml2::XMLPrinter&) const; 80 81 private: 82 83 /// Minkowski exponent value. 84 85 type minkowski_parameter; 86 87 #ifdef OPENNN_CUDA 88 #include "../../opennn-cuda/opennn_cuda/minkowski_error_cuda.h" 89 #endif 90 91 #ifdef OPENNN_MKL 92 #include "../../opennn-mkl/opennn_mkl/minkowski_error_mkl.h" 93 #endif 94 }; 95 96 } 97 98 #endif 99 100 101 // OpenNN: Open Neural Networks Library. 102 // Copyright(C) 2005-2020 Artificial Intelligence Techniques, SL. 103 // 104 // This library is free software; you can redistribute it and/or 105 // modify it under the terms of the GNU Lesser General Public 106 // License as published by the Free Software Foundation; either 107 // version 2.1 of the License, or any later version. 108 // 109 // This library is distributed in the hope that it will be useful, 110 // but WITHOUT ANY WARRANTY; without even the implied warranty of 111 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 112 // Lesser General Public License for more details. 113 114 // You should have received a copy of the GNU Lesser General Public 115 // License along with this library; if not, write to the Free Software 116 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 117