SHOGUN
v1.1.0
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
shogun
classifier
svm
SGDQN.h
Go to the documentation of this file.
1
#ifndef _SGDQN_H___
2
#define _SGDQN_H___
3
4
/*
5
SVM with Quasi-Newton stochastic gradient
6
Copyright (C) 2009- Antoine Bordes
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU Lesser General Public
10
License as published by the Free Software Foundation; either
11
version 2.1 of the License, or (at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
21
22
Shogun adjustments (w) 2011 Siddharth Kherada
23
*/
24
25
#include <
shogun/lib/common.h
>
26
#include <
shogun/machine/LinearMachine.h
>
27
#include <
shogun/features/DotFeatures.h
>
28
#include <
shogun/features/Labels.h
>
29
#include <
shogun/loss/LossFunction.h
>
30
31
namespace
shogun
32
{
34
class
CSGDQN
:
public
CLinearMachine
35
{
36
public
:
38
CSGDQN
();
39
44
CSGDQN
(
float64_t
C);
45
52
CSGDQN
(
53
float64_t
C,
CDotFeatures
* traindat,
54
CLabels
* trainlab);
55
56
virtual
~CSGDQN
();
57
62
virtual
inline
EClassifierType
get_classifier_type
() {
return
CT_SGDQN
; }
63
72
virtual
bool
train
(
CFeatures
* data=NULL);
73
80
inline
void
set_C
(
float64_t
c_neg,
float64_t
c_pos) { C1=c_neg; C2=c_pos; }
81
86
inline
float64_t
get_C1
() {
return
C1; }
87
92
inline
float64_t
get_C2
() {
return
C2; }
93
98
inline
void
set_epochs
(int32_t e) { epochs=e; }
99
104
inline
int32_t
get_epochs
() {
return
epochs; }
105
107
void
compute_ratio
(
float64_t
* W,
float64_t
* W_1,
float64_t
* B,
float64_t
* dst,int32_t dim,
float64_t
regularizer_lambda,
float64_t
loss);
108
110
void
combine_and_clip
(
float64_t
* Bc,
float64_t
* B,int32_t dim,
float64_t
c1,
float64_t
c2,
float64_t
v1,
float64_t
v2);
111
116
void
set_loss_function
(
CLossFunction
* loss_func);
117
122
inline
CLossFunction
*
get_loss_function
() {
SG_REF
(loss);
return
loss; }
123
125
inline
virtual
const
char
*
get_name
()
const
{
return
"SGDQN"
; }
126
127
protected
:
129
void
calibrate
();
130
131
private
:
132
void
init();
133
134
private
:
135
float64_t
t;
136
float64_t
C1;
137
float64_t
C2;
138
int32_t epochs;
139
int32_t skip;
140
int32_t count;
141
142
CLossFunction
* loss;
143
};
144
}
145
#endif
SHOGUN
Machine Learning Toolbox - Documentation