利用CAPI实现seq2seq预测模型中生成序列概率获取
Created by: ChinaLiuHao
请问我在用CAPI实现seq2seq预测模型时,只能得到生成序列的id,但是无法得到生成序列的打分值。请问下原因?
附:预测代码
int sentence_ids[] = {0, 33015, 10213, 4, 87713, 12908, 630;
paddle_ivector sentence = paddle_ivector_create(
sentence_ids, sizeof(sentence_ids) / sizeof(int), false, false);
CHECK(paddle_arguments_set_ids(in_args, 0, sentence));
int seq_pos_array[] = {0, sizeof(sentence_ids) / sizeof(int)};
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));
paddle_arguments out_args = paddle_arguments_create_none();
CHECK(paddle_gradient_machine_forward(machine,
in_args, out_args, false));
uint64_t total_size = 0;
paddle_arguments_get_size(out_args, &total_size);
cout << "#63\t" << total_size << endl;
paddle_ivector ivec = paddle_ivector_create_none();
paddle_arguments_get_ids(out_args, 0, ivec);
uint64_t vec_size = 0;
paddle_ivector_get_size(ivec, &vec_size);
int* array;
paddle_ivector_get(ivec, &array);
for (uint64_t i = 0; i < vec_size; i++) {
cout << array[i] << endl;
}