提交 8e002d6c 编写于 作者: S ShusenTang

update code 6.4

上级 02036d80
......@@ -99,7 +99,8 @@
}
],
"source": [
"def to_onehot(X, n_class): # 本函数已保存在d2lzh包中方便以后使用\n",
"# 本函数已保存在d2lzh_pytorch包中方便以后使用\n",
"def to_onehot(X, n_class): \n",
" # X shape: (batch, seq_len), output: seq_len elements of (batch, n_class)\n",
" return [one_hot(X[:, i], n_class) for i in range(X.shape[1])]\n",
"\n",
......@@ -303,7 +304,7 @@
},
"outputs": [],
"source": [
"# 本函数已保存在d2lzh包中方便以后使用\n",
"# 本函数已保存在d2lzh_pytorch包中方便以后使用\n",
"def train_and_predict_rnn(rnn, get_params, init_rnn_state, num_hiddens,\n",
" vocab_size, device, corpus_indices, idx_to_char,\n",
" char_to_idx, is_random_iter, num_epochs, num_steps,\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册