Exercise: Follow the instructions and implement model(). When examples[index] contains one dinosaur name (string), to create an example (X, Y), you can use this:
index = j % len(examples)
X = [None] + [char_to_ix[ch] for ch in examples[index]]
Y = X[1:] + [char_to_ix["\n"]]
Note that we use: index= j % len(examples), where j = 1….num_iterations, to make sure that examples[index] is always a valid statement (index is smaller than len(examples)). The first entry of X being None will be interpreted by rnn_forward() as setting x⟨0⟩=0⃗ x⟨0⟩=0→ . Further, this ensures that Y is equal to X but shifted one step to the left, and with an additional “\n” appended to signify the end of the dinosaur name.
本文介绍了一种基于字符级循环神经网络的恐龙姓名生成模型实现方法。通过使用特定的数据集,模型能够学习并生成类似恐龙姓名的字符串。具体实现中,通过循环迭代的方式创建训练样本,将每个恐龙姓名转换为字符级别的向量表示,然后将其输入到模型中进行训练。

被折叠的 条评论
为什么被折叠?



