Skip to content

why there is KeyError: -1 in prediction  #28

Open
@tianke0711

Description

@tianke0711

when code run here::

prediction_output = [[reversed_dict[y] for y in x] for x in prediction[:, 0, :]]

    with open("result.txt", "a") as f:
        for line in prediction_output:
            summary = list()
            for word in line:
                if word == "</s>":
                    break
                if word not in summary:
                    summary.append(word)
            print(" ".join(summary), file=f)

print('Summaries are saved to "result.txt"...')

there is error:


KeyError Traceback (most recent call last)
in
27 print('prediction:', prediction.shape)
28
---> 29 prediction_output = [[reversed_dict[y] for y in x] for x in prediction[:, 0, :]]
30
31

in (.0)
27 print('prediction:', prediction.shape)
28
---> 29 prediction_output = [[reversed_dict[y] for y in x] for x in prediction[:, 0, :]]
30
31

in (.0)
27 print('prediction:', prediction.shape)
28
---> 29 prediction_output = [[reversed_dict[y] for y in x] for x in prediction[:, 0, :]]
30
31

KeyError: -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions