Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
5a1e678b
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5a1e678b
编写于
6月 06, 2017
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"update macro and fix some part"
上级
beb26978
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
19 addition
and
25 deletion
+19
-25
paddle/optimizer/Tensor.h
paddle/optimizer/Tensor.h
+7
-2
paddle/optimizer/Tensor_test.cpp
paddle/optimizer/Tensor_test.cpp
+1
-3
paddle/optimizer/adadelta_optimizer.cc
paddle/optimizer/adadelta_optimizer.cc
+3
-6
paddle/optimizer/adagrad_optimizer.cc
paddle/optimizer/adagrad_optimizer.cc
+1
-2
paddle/optimizer/adam_optimizer.cc
paddle/optimizer/adam_optimizer.cc
+2
-4
paddle/optimizer/parameter_optimizer_test.cpp
paddle/optimizer/parameter_optimizer_test.cpp
+2
-4
paddle/optimizer/sgd_optmizer.cc
paddle/optimizer/sgd_optmizer.cc
+3
-4
未找到文件。
paddle/optimizer/Tensor.h
浏览文件 @
5a1e678b
...
...
@@ -14,10 +14,15 @@ namespace optimizer {
template
<
class
T
>
class
TensorT
{
public:
TensorT
(
size_t
h
,
size_t
w
,
T
*
data
)
:
height_
(
h
),
width_
(
w
),
data_
(
data_
)
{}
TensorT
(
T
*
data
,
int
size
)
:
height_
(
1
),
width_
(
size
),
data_
(
data
)
{}
TensorT
(
size_t
size
)
:
height_
(
1
),
width_
(
size
)
{
data_
=
new
T
[
size
];
}
TensorT
(
T
*
data
,
size_t
size
)
:
height_
(
1
),
width_
(
size
),
data_
(
data
)
{}
TensorT
(
T
*
data
,
size_t
h
,
size_t
w
)
:
height_
(
h
),
width_
(
w
),
data_
(
data_
)
{}
TensorT
(
const
TensorT
&
t
)
:
TensorT
(
1
,
t
.
size
(),
0
,
t
.
get_buffer
(),
false
,
false
)
{}
~
TensorT
()
{
if
(
data_
)
delete
data_
;
}
TensorT
&
operator
=
(
const
TensorT
&
t
)
{
this
->
width_
=
t
.
size
();
this
->
data_
=
t
.
get_buffer
();
...
...
paddle/optimizer/Tensor_test.cpp
浏览文件 @
5a1e678b
...
...
@@ -6,14 +6,12 @@ using namespace paddle;
using
namespace
paddle
::
optimizer
;
TEST
(
Tensor
,
indexer
)
{
real
*
ptr
=
new
real
[
3
];
Tensor
t
(
ptr
,
3
);
Tensor
t
(
3
);
for
(
auto
i
=
0
;
i
<
t
.
size
();
++
i
)
{
t
[
i
]
=
i
;
}
ASSERT_EQ
(
t
[
2
],
2
);
ASSERT_EQ
(
t
[
1
],
1
);
delete
ptr
;
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
paddle/optimizer/adadelta_optimizer.cc
浏览文件 @
5a1e678b
...
...
@@ -8,12 +8,9 @@ namespace optimizer {
void
AdadeltaOptimizer
::
set_weight
(
Tensor
*
p
)
{
parameter_
=
p
;
size_t
size
=
p
->
size
();
real
*
gptr
=
new
real
[
size
];
accum_gradient_
=
new
Tensor
(
gptr
,
size
);
real
*
dptr
=
new
real
[
size
];
accum_delta_
=
new
Tensor
(
dptr
,
size
);
real
*
dptr_current
=
new
real
[
size
];
update_delta_
=
new
Tensor
(
dptr_current
,
size
);
accum_gradient_
=
new
Tensor
(
size
);
accum_delta_
=
new
Tensor
(
size
);
update_delta_
=
new
Tensor
(
size
);
}
void
AdadeltaOptimizer
::
Update
(
const
Tensor
*
gradient
)
{
...
...
paddle/optimizer/adagrad_optimizer.cc
浏览文件 @
5a1e678b
...
...
@@ -8,8 +8,7 @@ namespace optimizer {
void
AdagradOptimizer
::
set_weight
(
Tensor
*
p
)
{
parameter_
=
p
;
size_t
size
=
p
->
size
();
real
*
gptr
=
new
real
[
size
];
accum_gradient_
=
new
Tensor
(
gptr
,
size
);
accum_gradient_
=
new
Tensor
(
size
);
}
void
AdagradOptimizer
::
Update
(
const
Tensor
*
gradient
)
{
...
...
paddle/optimizer/adam_optimizer.cc
浏览文件 @
5a1e678b
...
...
@@ -7,10 +7,8 @@ namespace optimizer {
void
AdamOptimizer
::
set_weight
(
Tensor
*
p
)
{
parameter_
=
p
;
size_t
size
=
p
->
size
();
real
*
mptr
=
new
real
[
size
];
momentums_
=
new
Tensor
(
mptr
,
size
);
real
*
vptr
=
new
real
[
size
];
velocitys_
=
new
Tensor
(
vptr
,
size
);
momentums_
=
new
Tensor
(
size
);
velocitys_
=
new
Tensor
(
size
);
}
void
AdamOptimizer
::
Update
(
const
Tensor
*
gradient
)
{
...
...
paddle/optimizer/parameter_optimizer_test.cpp
浏览文件 @
5a1e678b
...
...
@@ -11,8 +11,7 @@ using namespace paddle;
using
namespace
paddle
::
optimizer
;
Tensor
*
FillTensor
(
size_t
size
)
{
real
*
ptr
=
new
real
[
size
];
Tensor
*
param
=
new
Tensor
(
ptr
,
size
);
Tensor
*
param
=
new
Tensor
(
size
);
Tensor
&
p
=
*
param
;
for
(
auto
i
=
0
;
i
<
p
.
size
();
++
i
)
{
p
[
i
]
=
(
float
)
rand
()
/
(
float
)
RAND_MAX
;
...
...
@@ -21,8 +20,7 @@ Tensor* FillTensor(size_t size) {
}
Tensor
*
FixedTensor
(
size_t
size
)
{
real
*
ptr
=
new
real
[
size
];
Tensor
*
param
=
new
Tensor
(
ptr
,
size
);
Tensor
*
param
=
new
Tensor
(
size
);
Tensor
&
p
=
*
param
;
for
(
auto
i
=
0
;
i
<
p
.
size
();
++
i
)
{
p
[
i
]
=
i
;
...
...
paddle/optimizer/sgd_optmizer.cc
浏览文件 @
5a1e678b
...
...
@@ -6,11 +6,10 @@ namespace optimizer {
void
SGDOptimizer
::
set_weight
(
Tensor
*
p
)
{
parameter_
=
p
;
size_t
size
=
p
->
size
();
// TODO: fix it with align aware allocator bind to Tensor
if
(
momentum_
!=
0.0
)
{
real
*
ptr
=
new
real
[
size
];
momentums_
=
new
Tensor
(
ptr
,
size
);
size_t
size
=
p
->
size
();
// TODO: fix it with align aware allocator bind to Tensor
momentums_
=
new
Tensor
(
size
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录