SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
loss
LogLossMargin.cpp
浏览该文件的文档.
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
* Written (W) 2011 Shashwat Lal Das
8
* Written (W) 2012 Fernando José Iglesias García
9
* Copyright (c) 2011 Berlin Institute of Technology and Max-Planck-Society.
10
*/
11
12
#include <
shogun/loss/LogLossMargin.h
>
13
14
using namespace
shogun;
15
16
float64_t
CLogLossMargin::loss
(
float64_t
z)
17
{
18
if
(z >= 1)
19
return
log(1+exp(1-z));
20
21
return
1-z + log(1+exp(z-1));
22
}
23
24
float64_t
CLogLossMargin::first_derivative
(
float64_t
z)
25
{
26
if
(z < 1)
27
return
-1 / (exp(z-1) + 1);
28
29
float64_t
ez = exp(1-z);
30
return
-ez / (ez + 1);
31
}
32
33
float64_t
CLogLossMargin::second_derivative
(
float64_t
z)
34
{
35
float64_t
ez = exp(z-1);
36
37
return
ez / (ez + 1)*(ez + 1);
38
}
39
40
float64_t
CLogLossMargin::get_update
(
float64_t
prediction,
float64_t
label,
float64_t
eta_t,
float64_t
norm
)
41
{
42
SG_NOTIMPLEMENTED
43
return
-1;
44
}
45
46
float64_t
CLogLossMargin::get_square_grad
(
float64_t
prediction,
float64_t
label)
47
{
48
SG_NOTIMPLEMENTED
49
return
-1;
50
}
SHOGUN
机器学习工具包 - 项目文档