Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夏有凉风,冬有雪
Paddle
提交
6deb33d9
P
Paddle
项目概览
夏有凉风,冬有雪
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6deb33d9
编写于
2月 19, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Complete combined evaluator
上级
9a484425
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
8 deletion
+89
-8
paddle/gserver/evaluators/Evaluator.cpp
paddle/gserver/evaluators/Evaluator.cpp
+26
-6
paddle/gserver/evaluators/Evaluator.h
paddle/gserver/evaluators/Evaluator.h
+19
-1
paddle/gserver/gradientmachines/NeuralNetwork.cpp
paddle/gserver/gradientmachines/NeuralNetwork.cpp
+44
-1
未找到文件。
paddle/gserver/evaluators/Evaluator.cpp
浏览文件 @
6deb33d9
...
...
@@ -102,6 +102,10 @@ public:
virtual
void
distributeEval
(
ParameterClient2
*
client
)
{
mergeResultsOfAllClients
(
client
);
}
// Evaluator interface
protected:
std
::
string
getTypeImpl
()
const
{
return
"classification_error"
;
}
};
/**
...
...
@@ -140,6 +144,10 @@ public:
virtual
void
distributeEval
(
ParameterClient2
*
client
)
{
mergeResultsOfAllClients
(
client
);
}
// Evaluator interface
protected:
std
::
string
getTypeImpl
()
const
{
return
"seq_classification_error"
;
}
};
REGISTER_EVALUATOR
(
seq_classification_error
,
SequenceClassificationErrorEvaluator
);
...
...
@@ -230,6 +238,10 @@ public:
private:
IVectorPtr
cpuLabel_
;
MatrixPtr
cpuWeight_
;
// Evaluator interface
protected:
std
::
string
getTypeImpl
()
const
{
return
"sum"
;
}
};
/**
* @brief column sum Evaluator
...
...
@@ -337,10 +349,18 @@ public:
}
private:
ColumnSumEvaluator
()
{}
int32_t
colIdx_
;
size_t
colNum_
;
MatrixPtr
sum_
;
/* cpu matrix */
// Evaluator interface
protected:
std
::
string
getTypeImpl
()
const
{
if
(
colIdx_
==
-
1
)
return
"last-column-sum"
;
else
return
"column-sum"
;
}
};
void
AucEvaluator
::
start
()
{
...
...
@@ -791,7 +811,6 @@ void PrecisionRecallEvaluator::storeLocalValues() const {
void
PrecisionRecallEvaluator
::
getNames
(
std
::
vector
<
std
::
string
>*
names
)
{
this
->
storeLocalValues
();
names
->
clear
();
names
->
reserve
(
this
->
values_
.
size
());
for
(
auto
it
=
this
->
values_
.
begin
();
it
!=
this
->
values_
.
end
();
++
it
)
{
names
->
push_back
(
this
->
config_
.
name
()
+
"."
+
it
->
first
);
...
...
@@ -1080,12 +1099,13 @@ public:
}
};
REGISTER_EVALUATOR
(
value_printer
,
ValuePrinter
);
/**
* @brief print gradient of each layer.
*
* The config file api is gradient_printer_evaluator.
*/
class
GradientPrinter
:
public
Evaluator
{
class
GradientPrinter
:
public
NotGetable
Evaluator
{
public:
virtual
void
eval
(
const
NeuralNetwork
&
nn
)
{
for
(
const
std
::
string
&
name
:
config_
.
input_layers
())
{
...
...
@@ -1108,7 +1128,7 @@ REGISTER_EVALUATOR(gradient_printer, GradientPrinter);
*
* The config file api is maxid_printer_evaluator.
*/
class
MaxIdPrinter
:
public
Evaluator
{
class
MaxIdPrinter
:
public
NotGetable
Evaluator
{
private:
IVectorPtr
maxIds_
;
MatrixPtr
maxValues_
;
...
...
@@ -1150,7 +1170,7 @@ REGISTER_EVALUATOR(max_id_printer, MaxIdPrinter);
*
* The config file api is maxframe_printer_evaluator.
*/
class
MaxFramePrinter
:
public
Evaluator
{
class
MaxFramePrinter
:
public
NotGetable
Evaluator
{
private:
IVectorPtr
maxIds_
;
MatrixPtr
maxValues_
;
...
...
@@ -1237,7 +1257,7 @@ REGISTER_EVALUATOR(max_frame_printer, MaxFramePrinter);
* The config file api is seqtext_printer_evaluator.
*
*/
class
SequenceTextPrinter
:
public
Evaluator
{
class
SequenceTextPrinter
:
public
NotGetable
Evaluator
{
private:
/// dict_file, which contains a list of tokens
std
::
vector
<
std
::
string
>
dict_
;
...
...
paddle/gserver/evaluators/Evaluator.h
浏览文件 @
6deb33d9
...
...
@@ -119,7 +119,6 @@ public:
static
ClassRegistrar
<
Evaluator
>
registrar_
;
virtual
void
getNames
(
std
::
vector
<
std
::
string
>*
names
)
{
names
->
clear
();
names
->
push_back
(
config_
.
name
());
}
...
...
@@ -168,6 +167,25 @@ protected:
double
totalScore_
;
};
class
NotGetableEvaluator
:
public
Evaluator
{
// Evaluator interface
public:
void
getNames
(
std
::
vector
<
std
::
string
>*
names
)
{}
real
getValue
(
const
std
::
string
&
name
,
Error
*
err
)
const
{
if
(
err
!=
nullptr
)
{
*
err
=
Error
(
"Not implemented"
);
}
return
.0
f
;
}
std
::
string
getType
(
const
std
::
string
&
name
,
Error
*
err
)
const
{
if
(
err
!=
nullptr
)
{
*
err
=
Error
(
"Not implemented"
);
}
return
""
;
}
};
class
DummyEvaluator
:
public
Evaluator
{
public:
DummyEvaluator
()
{}
...
...
paddle/gserver/gradientmachines/NeuralNetwork.cpp
浏览文件 @
6deb33d9
...
...
@@ -306,7 +306,6 @@ void NeuralNetwork::onPassEnd() {
class
CombinedEvaluator
:
public
Evaluator
{
public:
CombinedEvaluator
()
{}
void
addEvaluator
(
std
::
unique_ptr
<
Evaluator
>&&
evaluator
)
{
evaluators_
.
emplace_back
(
std
::
move
(
evaluator
));
}
...
...
@@ -346,6 +345,50 @@ public:
protected:
std
::
vector
<
std
::
unique_ptr
<
Evaluator
>>
evaluators_
;
// Evaluator interface
public:
void
getNames
(
std
::
vector
<
std
::
string
>*
names
)
{
for
(
auto
&
eval
:
evaluators_
)
{
eval
->
getNames
(
names
);
}
}
real
getValue
(
const
std
::
string
&
name
,
Error
*
err
)
const
{
return
this
->
getMethodHelper
<
real
>
(
name
,
err
,
[
&
name
,
err
](
const
std
::
unique_ptr
<
Evaluator
>&
eval
)
{
return
eval
->
getValue
(
name
,
err
);
});
}
std
::
string
getValueStr
(
const
std
::
string
&
name
,
Error
*
err
)
const
{
return
this
->
getMethodHelper
<
std
::
string
>
(
name
,
err
,
[
&
name
,
err
](
const
std
::
unique_ptr
<
Evaluator
>&
eval
)
{
return
eval
->
getValueStr
(
name
,
err
);
});
}
std
::
string
getType
(
const
std
::
string
&
name
,
Error
*
err
)
const
{
return
this
->
getMethodHelper
<
std
::
string
>
(
name
,
err
,
[
&
name
,
err
](
const
std
::
unique_ptr
<
Evaluator
>&
eval
)
{
return
eval
->
getType
(
name
,
err
);
});
}
private:
template
<
typename
T
>
T
getMethodHelper
(
const
std
::
string
&
name
,
Error
*
err
,
const
std
::
function
<
T
(
const
std
::
unique_ptr
<
Evaluator
>&
)
>&
callback
)
const
{
for
(
auto
&
eval
:
evaluators_
)
{
std
::
vector
<
std
::
string
>
names
;
eval
->
getNames
(
&
names
);
if
(
std
::
find
(
names
.
begin
(),
names
.
end
(),
name
)
!=
names
.
end
())
{
return
callback
(
eval
);
}
}
if
(
err
!=
nullptr
)
*
err
=
Error
(
"No such key %s"
,
name
.
c_str
());
return
T
();
}
};
Evaluator
*
NeuralNetwork
::
makeEvaluator
()
const
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录