import numpy as np import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import SimpleRNN, Dense, Embedding from tensorflow.keras.preprocessing.text import Tokenizer from tensorflow.keras.preprocessing.sequence import pad_sequences from tensorflow.keras.utils import to_categorical
# 读取数据 defload_data(filepath, maxlen=100): withopen(filepath, 'r', encoding='utf-8') as file: text = file.read() # 将文本转换为小写 text = text.lower() return text, maxlen
Copyright:
Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.