cross_entropy_error.h
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// C R O S S E N T R O P Y 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 CROSSENTROPYERROR_H
10#define CROSSENTROPYERROR_H
11
12// System includes
13
14#include <iostream>
15#include <fstream>
16#include <math.h>
17
18// OpenNN includes
19
20#include "loss_index.h"
21#include "data_set.h"
22#include "config.h"
23
24namespace OpenNN
25{
26
28
31
33{
34
35public:
36
37 // Constructors
38
39 explicit CrossEntropyError();
40
42
43 // Destructor
44
45 virtual ~CrossEntropyError();
46
47 // Error methods
48
49 void calculate_error(const DataSetBatch&,
52
53 void calculate_binary_error(const DataSetBatch&,
56
57 void calculate_multiple_error(const DataSetBatch& batch,
60
61 // Gradient methods
62
63 void calculate_output_delta(const DataSetBatch&,
66
67 void calculate_binary_output_delta(const DataSetBatch&,
70
71 void calculate_multiple_output_delta(const DataSetBatch&,
74
75 string get_error_type() const;
76 string get_error_type_text() const;
77
78 // Serialization methods
79
81
83
84#ifdef OPENNN_CUDA
85 #include "../../opennn-cuda/opennn-cuda/cross_entropy_error_cuda.h"
86#endif
87
88};
89
90}
91
92#endif
93
94
95// OpenNN: Open Neural Networks Library.
96// Copyright(C) 2005-2021 Artificial Intelligence Techniques, SL.
97//
98// This library is free software; you can redistribute it and/or
99// modify it under the terms of the GNU Lesser General Public
100// License as published by the Free Software Foundation; either
101// version 2.1 of the License, or any later version.
102//
103// This library is distributed in the hope that it will be useful,
104// but WITHOUT ANY WARRANTY; without even the implied warranty of
105// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
106// Lesser General Public License for more details.
107
108// You should have received a copy of the GNU Lesser General Public
109// License along with this library; if not, write to the Free Software
110// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
This class represents the cross entropy error term, used for predicting probabilities.
void from_XML(const tinyxml2::XMLDocument &)
string get_error_type() const
Returns a string with the name of the cross entropy error loss type, "CROSS_ENTROPY_ERROR".
virtual ~CrossEntropyError()
Destructor.
void write_XML(tinyxml2::XMLPrinter &) const
string get_error_type_text() const
Returns a string with the name of the cross entropy error loss type in text format.
This class represents the concept of data set for data modelling problems, such as approximation,...
Definition: data_set.h:57
This abstract class represents the concept of loss index composed of an error term and a regularizati...
Definition: loss_index.h:48