Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
a7c4d0c0
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看板
提交
a7c4d0c0
编写于
7月 12, 2017
作者:
C
caoying03
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into print_attention_weight
上级
5e87a1bb
378527ac
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
13 deletion
+26
-13
cmake/generic.cmake
cmake/generic.cmake
+1
-1
paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp
paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp
+8
-2
paddle/gserver/gradientmachines/RecurrentGradientMachine.h
paddle/gserver/gradientmachines/RecurrentGradientMachine.h
+0
-2
paddle/parameter/Argument.cpp
paddle/parameter/Argument.cpp
+9
-7
python/paddle/trainer_config_helpers/networks.py
python/paddle/trainer_config_helpers/networks.py
+8
-1
未找到文件。
cmake/generic.cmake
浏览文件 @
a7c4d0c0
...
@@ -93,7 +93,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
...
@@ -93,7 +93,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
if
(
NOT APPLE
)
if
(
NOT APPLE
)
find_package
(
Threads REQUIRED
)
find_package
(
Threads REQUIRED
)
link_libraries
(
${
CMAKE_THREAD_LIBS_INIT
}
)
link_libraries
(
${
CMAKE_THREAD_LIBS_INIT
}
)
set
(
CMAKE_CXX_LINK_EXECUTABLE
"
${
CMAKE_CXX_LINK_EXECUTABLE
}
-ldl"
)
set
(
CMAKE_CXX_LINK_EXECUTABLE
"
${
CMAKE_CXX_LINK_EXECUTABLE
}
-ldl
-lrt
"
)
endif
(
NOT APPLE
)
endif
(
NOT APPLE
)
function
(
merge_static_libs TARGET_NAME
)
function
(
merge_static_libs TARGET_NAME
)
...
...
paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp
浏览文件 @
a7c4d0c0
...
@@ -1395,17 +1395,23 @@ void RecurrentGradientMachine::createDataOutlinkCopySizeInfo(
...
@@ -1395,17 +1395,23 @@ void RecurrentGradientMachine::createDataOutlinkCopySizeInfo(
batchMachineStartPos_
.
resize
(
totalSeqNum
+
1
,
0
);
batchMachineStartPos_
.
resize
(
totalSeqNum
+
1
,
0
);
if
(
isSeq
)
{
if
(
isSeq
)
{
ICpuGpuVectorPtr
inputSeqStartPos
=
outArgs
[
0
].
sequenceStartPositions
;
ICpuGpuVectorPtr
inputSeqStartPos
=
outArgs
[
0
].
sequenceStartPositions
;
CHECK_EQ
(
inputSeqStartPos
->
getSize
()
-
1
,
finalPaths_
.
size
());
CHECK_EQ
(
static_cast
<
size_t
>
(
inputSeqStartPos
->
getSize
()
-
1
),
getBeamSize
()
>
1
?
finalPaths_
.
size
()
:
finalPaths_
[
0
].
size
());
int
*
starts
=
inputSeqStartPos
->
getMutableData
(
false
);
int
*
starts
=
inputSeqStartPos
->
getMutableData
(
false
);
int
seqId
=
0
;
int
seqId
=
0
;
for
(
int
i
=
0
;
i
<
finalPaths_
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
finalPaths_
.
size
();
++
i
)
{
for
(
int
j
=
0
;
j
<
finalPaths_
[
i
].
size
();
++
j
)
{
for
(
int
j
=
0
;
j
<
finalPaths_
[
i
].
size
();
++
j
)
{
copySize
[
seqId
]
=
starts
[
i
+
1
]
-
starts
[
i
];
copySize
[
seqId
]
=
getBeamSize
()
>
1
?
starts
[
i
+
1
]
-
starts
[
i
]
:
starts
[
j
+
1
]
-
starts
[
j
];
batchMachineStartPos_
[
seqId
+
1
]
=
batchMachineStartPos_
[
seqId
+
1
]
=
batchMachineStartPos_
[
seqId
]
+
finalPaths_
[
i
][
j
].
ids
.
size
();
batchMachineStartPos_
[
seqId
]
+
finalPaths_
[
i
][
j
].
ids
.
size
();
seqId
++
;
seqId
++
;
}
}
}
}
}
else
{
for
(
size_t
i
=
0
;
i
<
finalPaths_
[
0
].
size
();
++
i
)
batchMachineStartPos_
[
i
+
1
]
=
batchMachineStartPos_
[
i
]
+
finalPaths_
[
0
][
i
].
ids
.
size
();
}
}
}
}
...
...
paddle/gserver/gradientmachines/RecurrentGradientMachine.h
浏览文件 @
a7c4d0c0
...
@@ -477,8 +477,6 @@ private:
...
@@ -477,8 +477,6 @@ private:
* outlinks.
* outlinks.
* @note In beam search, only one generated sequence with the hightest log
* @note In beam search, only one generated sequence with the hightest log
* probabilites are retained.
* probabilites are retained.
* @param machineIdVec : select a row of output matrix in each frame
* that the generation process expanded.
*/
*/
void
createDataOutlink
();
void
createDataOutlink
();
void
createDataOutlinkCopySizeInfo
(
bool
isSeq
,
void
createDataOutlinkCopySizeInfo
(
bool
isSeq
,
...
...
paddle/parameter/Argument.cpp
浏览文件 @
a7c4d0c0
...
@@ -310,8 +310,8 @@ void Argument::concat(const std::vector<Argument>& args,
...
@@ -310,8 +310,8 @@ void Argument::concat(const std::vector<Argument>& args,
auto
copyIds
=
[
batchSize
,
stream
](
IVectorPtr
&
dst
,
auto
copyIds
=
[
batchSize
,
stream
](
IVectorPtr
&
dst
,
const
IVectorPtr
&
src
,
const
IVectorPtr
&
src
,
int
s
tartRow
,
int
desS
tartRow
,
int
pos
,
int
srcStartRow
,
int
size
,
int
size
,
bool
useGpu
)
{
bool
useGpu
)
{
if
(
!
src
)
{
if
(
!
src
)
{
...
@@ -319,13 +319,14 @@ void Argument::concat(const std::vector<Argument>& args,
...
@@ -319,13 +319,14 @@ void Argument::concat(const std::vector<Argument>& args,
return
;
return
;
}
}
IVector
::
resizeOrCreate
(
dst
,
batchSize
,
useGpu
);
IVector
::
resizeOrCreate
(
dst
,
batchSize
,
useGpu
);
dst
->
subVec
(
startRow
,
size
)
->
copyFrom
(
*
src
->
subVec
(
pos
,
size
),
stream
);
dst
->
subVec
(
desStartRow
,
size
)
->
copyFrom
(
*
src
->
subVec
(
srcStartRow
,
size
),
stream
);
};
};
auto
copyStrs
=
[
batchSize
,
stream
](
SVectorPtr
&
dst
,
auto
copyStrs
=
[
batchSize
,
stream
](
SVectorPtr
&
dst
,
const
SVectorPtr
&
src
,
const
SVectorPtr
&
src
,
int
s
tartRow
,
int
desS
tartRow
,
int
pos
,
int
srcStartRow
,
int
size
,
int
size
,
bool
useGpu
)
{
bool
useGpu
)
{
if
(
!
src
)
{
if
(
!
src
)
{
...
@@ -337,8 +338,9 @@ void Argument::concat(const std::vector<Argument>& args,
...
@@ -337,8 +338,9 @@ void Argument::concat(const std::vector<Argument>& args,
}
else
{
}
else
{
dst
->
resize
(
batchSize
);
dst
->
resize
(
batchSize
);
}
}
std
::
copy
(
std
::
copy
(
src
->
begin
()
+
srcStartRow
,
src
->
begin
()
+
pos
,
src
->
begin
()
+
pos
+
size
,
dst
->
begin
()
+
startRow
);
src
->
begin
()
+
srcStartRow
+
size
,
dst
->
begin
()
+
desStartRow
);
};
};
dataId
=
args
[
0
].
dataId
;
dataId
=
args
[
0
].
dataId
;
...
...
python/paddle/trainer_config_helpers/networks.py
浏览文件 @
a7c4d0c0
...
@@ -1370,7 +1370,14 @@ def simple_attention(encoded_sequence,
...
@@ -1370,7 +1370,14 @@ def simple_attention(encoded_sequence,
param_attr
=
softmax_param_attr
,
param_attr
=
softmax_param_attr
,
name
=
"%s_softmax"
%
name
,
name
=
"%s_softmax"
%
name
,
bias_attr
=
False
)
bias_attr
=
False
)
return
attention_weight
scaled
=
scaling_layer
(
weight
=
attention_weight
,
input
=
encoded_sequence
,
name
=
'%s_scaling'
%
name
)
return
pooling_layer
(
input
=
scaled
,
pooling_type
=
SumPooling
(),
name
=
"%s_pooling"
%
name
),
attention_weight
def
inputs
(
layers
,
*
args
):
def
inputs
(
layers
,
*
args
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录