Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paddle_arguments_set_sequence_start_pos 作用是什么? #4464

Closed
VamWolf opened this issue Sep 28, 2017 · 2 comments
Closed

paddle_arguments_set_sequence_start_pos 作用是什么? #4464

VamWolf opened this issue Sep 28, 2017 · 2 comments
Labels
User 用于标记用户问题

Comments

@VamWolf
Copy link

VamWolf commented Sep 28, 2017

尝试写一下paddle 的capi...确实挺麻烦. 每个api ,都得查源码才稍微了解,

@lcy-seso
Copy link
Contributor

@ranqiu92 @peterzhang2029 请帮忙回答一下关于 CAPI 相关的问题吧,谢谢了。

@lcy-seso lcy-seso added the User 用于标记用户问题 label Sep 28, 2017
@peterzhang2029
Copy link
Contributor

peterzhang2029 commented Sep 28, 2017

C-API提供了paddle_arguments_set_sequence_start_pos接口来标记每个样本里序列的起始位置,有四个参数:

  1. 输入的paddle_arguments;
  2. 输入paddle_arguments的index;
  3. nestedLevel(如果用来控制双层序列中的sub_sequence需要设置为1);
  4. 用来指示每个样本的起始位置的paddle_ivector变量;

示例代码如下:

int seq_pos_array[] = {0, 1, 3, 6};
paddle_ivector seq_pos = paddle_ivector_create(
    seq_pos_array, sizeof(seq_pos_array) / sizeof(int), false, false);
CHECK(paddle_arguments_set_sequence_start_pos(in_args, 0, 0, seq_pos));

输入数据为:

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
26 27 28 29 30

数据的每行表示一个长度为5的特征向量,数据格式为dense vector。

其中,seq_pos_arry 的前3个元素表示对应位置的样本中序列开始的位置,而最后一个元素表示输入数据中所有的dense vector的数量。通过调用paddle_arguments_set_sequence_start_pos接口,示例代码将输入数据转化为3个dense vector sequece类型的样本数据:

[[[1 2 3 4 5]],

[[6 7 8 9 10],
[11 12 13 14 15]],

[[16 17 18 19 20],
[21 22 23 24 25],
[26 27 28 29 30]]]

类似的issue #3969

@NHZlX NHZlX closed this as completed Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User 用于标记用户问题
Projects
None yet
Development

No branches or pull requests

4 participants