Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
00809c78
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
00809c78
编写于
6月 14, 2019
作者:
A
alexey-milovidov
提交者:
GitHub
6月 14, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5623 from yandex/Quid37-lin_ref_perf
Merging PR #5505
上级
152294a1
95c75376
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
28 deletion
+20
-28
dbms/src/AggregateFunctions/AggregateFunctionMLMethod.cpp
dbms/src/AggregateFunctions/AggregateFunctionMLMethod.cpp
+9
-10
dbms/src/AggregateFunctions/AggregateFunctionMLMethod.h
dbms/src/AggregateFunctions/AggregateFunctionMLMethod.h
+11
-18
未找到文件。
dbms/src/AggregateFunctions/AggregateFunctionMLMethod.cpp
浏览文件 @
00809c78
...
...
@@ -49,8 +49,8 @@ namespace
auto
l2_reg_coef
=
Float64
(
0.1
);
UInt32
batch_size
=
15
;
std
::
string
weights_updater_name
=
"
\'
SGD
\'
"
;
std
::
shared
_ptr
<
IGradientComputer
>
gradient_computer
;
std
::
string
weights_updater_name
=
"
SGD
"
;
std
::
unique
_ptr
<
IGradientComputer
>
gradient_computer
;
if
(
!
parameters
.
empty
())
{
...
...
@@ -66,20 +66,19 @@ namespace
}
if
(
parameters
.
size
()
>
3
)
{
weights_updater_name
=
applyVisitor
(
FieldVisitorToString
(),
parameters
[
3
]);
if
(
weights_updater_name
!=
"
\'
SGD
\'
"
&&
weights_updater_name
!=
"
\'
Momentum
\'
"
&&
weights_updater_name
!=
"
\'
Nesterov
\'
"
)
{
throw
Exception
(
"Invalid parameter for weights updater"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
}
weights_updater_name
=
parameters
[
3
].
safeGet
<
String
>
();
if
(
weights_updater_name
!=
"SGD"
&&
weights_updater_name
!=
"Momentum"
&&
weights_updater_name
!=
"Nesterov"
)
throw
Exception
(
"Invalid parameter for weights updater. The only supported are 'SGD', 'Momentum' and 'Nesterov'"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
}
if
(
std
::
is_same
<
Method
,
FuncLinearRegression
>::
value
)
{
gradient_computer
=
std
::
make_
shared
<
LinearRegression
>
();
gradient_computer
=
std
::
make_
unique
<
LinearRegression
>
();
}
else
if
(
std
::
is_same
<
Method
,
FuncLogisticRegression
>::
value
)
{
gradient_computer
=
std
::
make_
shared
<
LogisticRegression
>
();
gradient_computer
=
std
::
make_
unique
<
LogisticRegression
>
();
}
else
{
...
...
@@ -88,7 +87,7 @@ namespace
return
std
::
make_shared
<
Method
>
(
argument_types
.
size
()
-
1
,
gradient_computer
,
std
::
move
(
gradient_computer
)
,
weights_updater_name
,
learning_rate
,
l2_reg_coef
,
...
...
dbms/src/AggregateFunctions/AggregateFunctionMLMethod.h
浏览文件 @
00809c78
...
...
@@ -37,8 +37,7 @@ public:
Float64
l2_reg_coef
,
Float64
target
,
const
IColumn
**
columns
,
size_t
row_num
)
=
0
;
size_t
row_num
)
=
0
;
virtual
void
predict
(
ColumnVector
<
Float64
>::
Container
&
container
,
...
...
@@ -201,9 +200,8 @@ private:
};
/**
* LinearModelData is a class which manages current state of learning
*/
/** LinearModelData is a class which manages current state of learning
*/
class
LinearModelData
{
public:
...
...
@@ -249,9 +247,8 @@ private:
std
::
shared_ptr
<
IGradientComputer
>
gradient_computer
;
std
::
shared_ptr
<
IWeightsUpdater
>
weights_updater
;
/**
* The function is called when we want to flush current batch and update our weights
*/
/** The function is called when we want to flush current batch and update our weights
*/
void
update_state
();
};
...
...
@@ -268,7 +265,7 @@ public:
explicit
AggregateFunctionMLMethod
(
UInt32
param_num
,
std
::
shared
_ptr
<
IGradientComputer
>
gradient_computer
,
std
::
unique
_ptr
<
IGradientComputer
>
gradient_computer
,
std
::
string
weights_updater_name
,
Float64
learning_rate
,
Float64
l2_reg_coef
,
...
...
@@ -300,19 +297,15 @@ public:
void
create
(
AggregateDataPtr
place
)
const
override
{
std
::
shared_ptr
<
IWeightsUpdater
>
new_weights_updater
;
if
(
weights_updater_name
==
"
\'
SGD
\'
"
)
{
if
(
weights_updater_name
==
"SGD"
)
new_weights_updater
=
std
::
make_shared
<
StochasticGradientDescent
>
();
}
else
if
(
weights_updater_name
==
"
\'
Momentum
\'
"
)
{
else
if
(
weights_updater_name
==
"Momentum"
)
new_weights_updater
=
std
::
make_shared
<
Momentum
>
();
}
else
if
(
weights_updater_name
==
"
\'
Nesterov
\'
"
)
{
else
if
(
weights_updater_name
==
"Nesterov"
)
new_weights_updater
=
std
::
make_shared
<
Nesterov
>
();
}
else
{
else
throw
Exception
(
"Illegal name of weights updater (should have been checked earlier)"
,
ErrorCodes
::
LOGICAL_ERROR
);
}
new
(
place
)
Data
(
learning_rate
,
l2_reg_coef
,
param_num
,
batch_size
,
gradient_computer
,
new_weights_updater
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录