SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
evaluation
GradientResult.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Copyright (C) 2012 Jacob Walker
8
*/
9
10
#ifndef CGRADIENTRESULT_H_
11
#define CGRADIENTRESULT_H_
12
13
#include <
shogun/evaluation/EvaluationResult.h
>
14
#include <
shogun/lib/Map.h
>
15
#include <
shogun/lib/SGString.h
>
16
17
namespace
shogun
18
{
19
25
class
CGradientResult
:
public
CEvaluationResult
26
{
27
28
public
:
29
30
/*Constructor*/
31
CGradientResult
();
32
33
/*Destructor*/
34
virtual
~CGradientResult
();
35
41
inline
virtual
const
char
*
get_name
()
const
42
{
43
return
"GradientResult"
;
44
}
45
51
virtual
EEvaluationResultType
get_result_type
()
52
{
53
return
GRADIENTEVALUATION_RESULT
;
54
}
55
57
SGVector<float64_t>
quantity
;
58
60
CMap<TParameter*, SGVector<float64_t>
>
gradient
;
61
63
CMap<TParameter*, CSGObject*>
parameter_dictionary
;
64
66
index_t
total_variables
;
67
71
void
print_result
()
72
{
73
SG_SPRINT
(
"Quantity: ["
);
74
75
for
(
index_t
i = 0; i <
quantity
.
vlen
; i++)
76
SG_SPRINT
(
"%f, "
,
quantity
[i]);
77
78
SG_SPRINT
(
"] "
);
79
80
SG_SPRINT
(
"Gradient: ["
);
81
82
for
(
index_t
i = 0; i <
gradient
.
get_num_elements
(); i++)
83
{
84
char
* name =
gradient
.
get_node_ptr
(i)->key->m_name;
85
for
(
index_t
j = 0; j <
gradient
.
get_element_ptr
(i)->
vlen
; j++)
86
SG_SPRINT
(
"%s: %f, "
, (*
gradient
.
get_element_ptr
(i))[j], name);
87
}
88
SG_SPRINT
(
"]\n"
);
89
90
SG_SPRINT
(
"Total Variables: %i\n"
,
total_variables
);
91
92
}
93
};
94
95
}
/* namespace shogun */
96
97
#endif
/* CGRADIENTRESULT_H_ */
SHOGUN
Machine Learning Toolbox - Documentation