python大法好! 这三行中的第二行代码可以说尽显霸气了!

Posted openglnewbee

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python大法好! 这三行中的第二行代码可以说尽显霸气了!相关的知识,希望对你有一定的参考价值。

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.

以上是关于python大法好! 这三行中的第二行代码可以说尽显霸气了!的主要内容,如果未能解决你的问题,请参考以下文章