keras pad_序列做什么?

2024-06-01 21:38:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在keras中编写一个文本char-rnn,为此,我必须首先将文本转换为序列,然后填充序列。但我在执行这一步骤时遇到了很多麻烦。我相信这是因为我对这个函数本身(pad_sequence)的理解有偏差或缺乏。我试着用谷歌搜索它,但没有找到任何好的教程,而且在kerasdocs中也没有太多的解释。

有谁能告诉我pad_sequence是怎么回事和什么?为什么我们应该在输入之前填充序列(这里是字符级别)。

请以这篇课文为例?

Take the 50-year-old man diagnosed with prostate cancer in my clinic at Brigham and Women's Hospital in Boston. He received a novel procedure to remove his prostate, and later received focused radiation to try to eradicate any remaining cancer. Unfortunately, his disease returned a year later. But after two new therapies, his cancer now appears in check. And if his cancer does spread, a host of other treatments — including many not even on the market yet — may put his cancer back in remission.


Tags: andthetoin文本序列yearkeras