内容参照:Example of NLP via Keras LSTM
数据:
git clone https://github.com/wojzaremba/lstm
mv lstm/data .
\rm -rf lstm
添加了一些必须的import后的可执行代码(注意by default,以下代码迭代40次,需要时间比较长,TensorFlow/Keras 尽可能会使用GPU的一些计算指令,耗电量也不小):
import pathlib, os
import collections
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras