Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

attention代码实例求解惑_2

Open chenbblei opened this issue 8 years ago • 3 comments

use the first 3 samples for generation

    gen_data = []
    gen_num = 3
    for item in paddle.dataset.wmt14.gen(dict_size)():
        gen_data.append([item[0]])
        if len(gen_data) == gen_num:
            break

    beam_size = 3
    beam_gen = seq_to_seq_net(source_dict_dim, target_dict_dim,
                              is_generating, beam_size)

    # get the trained model, whose bleu = 26.92
    parameters = paddle.dataset.wmt14.model()

    # prob is the prediction probabilities, and id is the prediction word.
    beam_result = paddle.infer(
        output_layer=beam_gen,
        parameters=parameters,
        input=gen_data,
        field=['prob', 'id'])

在示例中beam_gen是一个int32类型的list,假设我的beam_gen是一个浮点数组该如何修改

chenbblei avatar May 04 '18 03:05 chenbblei

beam_gen 可能就是 word id,没法是 float

Superjomn avatar May 04 '18 13:05 Superjomn

@Superjomn 应该不是这样的

chenbblei avatar May 07 '18 06:05 chenbblei

没人回答

chenbblei avatar May 14 '18 06:05 chenbblei