{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":10737,"databundleVersionId":290346,"sourceType":"competition"},{"sourceId":873652,"sourceType":"datasetVersion","datasetId":465057},{"sourceId":1123414,"sourceType":"datasetVersion","datasetId":631265}],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# RNN循环神经网络 评论","metadata":{}},{"cell_type":"code","source":"import pandas as pd # 导入Pandas\nimport numpy as np # 导入NumPy\ndir_train = '/kaggle/input/product-comments/Clothing Reviews.csv'\ndf_train = pd.read_csv(dir_train) # 读入训练集\ndf_train.head() # 输出部分数据","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-09-04T06:56:58.781408Z","iopub.execute_input":"2025-09-04T06:56:58.781583Z","iopub.status.idle":"2025-09-04T06:57:01.778360Z","shell.execute_reply.started":"2025-09-04T06:56:58.781567Z","shell.execute_reply":"2025-09-04T06:57:01.777612Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from tensorflow.keras.preprocessing.text import Tokenizer\n# 导入分词工具\nfrom tensorflow.keras.preprocessing.sequence import pad_sequences","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:03:24.926321Z","iopub.execute_input":"2025-09-04T07:03:24.926917Z","iopub.status.idle":"2025-09-04T07:03:25.010404Z","shell.execute_reply.started":"2025-09-04T07:03:24.926881Z","shell.execute_reply":"2025-09-04T07:03:25.009700Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train_lst = df_train[\"Review Text\"].values # 将评论读入张量(训练集)\ny_train = df_train[\"Rating\"].values # 构建标签集\ndictionary_size = 20000 # 设定词典的大小\ntokenizer = Tokenizer(num_words=dictionary_size) # 初始化词典\ntokenizer.fit_on_texts( X_train_lst ) # 使用训练集创建词典索引\n# 为所有的单词分配索引值，完成分词工作\nX_train_tokenized_lst = tokenizer.texts_to_sequences(X_train_lst)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:03:55.361952Z","iopub.execute_input":"2025-09-04T07:03:55.362192Z","iopub.status.idle":"2025-09-04T07:03:56.593545Z","shell.execute_reply.started":"2025-09-04T07:03:55.362175Z","shell.execute_reply":"2025-09-04T07:03:56.592989Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt # 导入matplotlib\nword_per_comment = [len(comment) for comment in X_train_tokenized_lst]\nplt.hist(word_per_comment, bins = np.arange(0,500,10)) # 显示评论长度分布\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:03:59.170491Z","iopub.execute_input":"2025-09-04T07:03:59.171211Z","iopub.status.idle":"2025-09-04T07:03:59.506201Z","shell.execute_reply.started":"2025-09-04T07:03:59.171185Z","shell.execute_reply":"2025-09-04T07:03:59.505455Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.preprocessing.sequence import pad_sequences \nmax_comment_length = 100 # 设定评论输入长度为100，并填充默认值(如字数少于100)\nX_train = pad_sequences(X_train_tokenized_lst, maxlen=max_comment_length)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:04:02.816819Z","iopub.execute_input":"2025-09-04T07:04:02.817587Z","iopub.status.idle":"2025-09-04T07:04:02.935127Z","shell.execute_reply.started":"2025-09-04T07:04:02.817564Z","shell.execute_reply":"2025-09-04T07:04:02.934340Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.models import Sequential # 导入贯序模型\nfrom keras.layers import Embedding #导入词嵌入层\nfrom keras.layers import Dense #导入全连接层\nfrom keras.layers import SimpleRNN #导入SimpleRNN层\nfrom tensorflow.keras.optimizers import Adam","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:10:53.424726Z","iopub.execute_input":"2025-09-04T07:10:53.425438Z","iopub.status.idle":"2025-09-04T07:10:53.441374Z","shell.execute_reply.started":"2025-09-04T07:10:53.425414Z","shell.execute_reply":"2025-09-04T07:10:53.440686Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"embedding_vecor_length = 60 # 设定词嵌入向量长度为60\nrnn = Sequential() # 贯序模型\nrnn.add(Embedding(dictionary_size, embedding_vecor_length)) # 加入词嵌入层\nrnn.add(SimpleRNN(100)) # 加入SimpleRNN层\nrnn.add(Dense(10, activation='relu')) # 加入全连接层\nrnn.add(Dense(6, activation='softmax')) # 加入分类输出层\nrnn.compile(loss='sparse_categorical_crossentropy', #损失函数\n            optimizer=Adam(learning_rate=0.001), # 优化器可自定义学习率\n            metrics=['acc']) # 评估指标","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:11:21.227971Z","iopub.execute_input":"2025-09-04T07:11:21.228762Z","iopub.status.idle":"2025-09-04T07:11:21.245128Z","shell.execute_reply.started":"2025-09-04T07:11:21.228730Z","shell.execute_reply":"2025-09-04T07:11:21.244308Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"history = rnn.fit(X_train, y_train, \n                    validation_split = 0.3, \n                    epochs=10, \n                    batch_size=64)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:11:23.337308Z","iopub.execute_input":"2025-09-04T07:11:23.337863Z","iopub.status.idle":"2025-09-04T07:11:55.250392Z","shell.execute_reply.started":"2025-09-04T07:11:23.337824Z","shell.execute_reply":"2025-09-04T07:11:55.249794Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(rnn.summary()) #打印网络模型","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:08:02.109336Z","iopub.execute_input":"2025-09-04T07:08:02.109610Z","iopub.status.idle":"2025-09-04T07:08:02.125453Z","shell.execute_reply.started":"2025-09-04T07:08:02.109588Z","shell.execute_reply":"2025-09-04T07:08:02.124659Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.models import Sequential # 导入贯序模型\nfrom keras.layers import Embedding #导入词嵌入层\nfrom keras.layers import Dense #导入全连接层\nfrom keras.layers import LSTM #导入LSTM层","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-04T07:07:42.633424Z","iopub.execute_input":"2025-09-04T07:07:42.633683Z","iopub.status.idle":"2025-09-04T07:07:42.637541Z","shell.execute_reply.started":"2025-09-04T07:07:42.633663Z","shell.execute_reply":"2025-09-04T07:07:42.636895Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"embedding_vecor_length = 60 # 设定词嵌入向量长度为60\nlstm = Sequential() # 贯序模型\nlstm.add(Embedding(dictionary_size, embedding_vecor_length, \n          input_length=max_comment_length)) # 加入词嵌入层\nlstm.add(LSTM(100)) # 加入LSTM层\nlstm.add(Dense(10, activation='relu')) # 加入全连接层\nlstm.add(Dense(6, activation='softmax')) # 加入分类输出层\nlstm.compile(loss='sparse_categorical_crossentropy', #损失函数\n             optimizer = 'adam', # 优化器\n             metrics = ['acc']) # 评估指标\nhistory = rnn.fit(X_train, y_train, \n                    validation_split = 0.3,\n                    epochs=10, \n                    batch_size=64)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# 一层卷积 与 GRU","metadata":{}},{"cell_type":"code","source":"import numpy as np # 导入NumPy\nimport pandas as pd # 导入Pandas\ndf_train = pd.read_csv('/kaggle/input/new-earth/exoTrain.csv') # 导入训练集\ndf_test = pd.read_csv('/kaggle/input/new-earth/exoTest.csv') # 导入测试集\nprint(df_train.head()) # 输入头几行数据\nprint(df_train.info()) # 输出训练集信息","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:03:55.543810Z","iopub.execute_input":"2024-02-09T15:03:55.544186Z","iopub.status.idle":"2024-02-09T15:04:02.969260Z","shell.execute_reply.started":"2024-02-09T15:03:55.544159Z","shell.execute_reply":"2024-02-09T15:04:02.968328Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.utils import shuffle # 导入乱序工具\ndf_train = shuffle(df_train) # 乱序训练集\ndf_test = shuffle(df_test)  # 乱序测试集","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:04:06.256372Z","iopub.execute_input":"2024-02-09T15:04:06.257248Z","iopub.status.idle":"2024-02-09T15:04:06.333625Z","shell.execute_reply.started":"2024-02-09T15:04:06.257210Z","shell.execute_reply":"2024-02-09T15:04:06.332818Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train = df_train.iloc[:, 1:].values # 构建特征集（训练）\ny_train = df_train.iloc[:, 0].values # 构建标签集（训练）\nX_test = df_test.iloc[:, 1:].values # 构建特征集（测试）\ny_test = df_test.iloc[:, 0].values # 构建标签集（测试）\ny_train = y_train - 1 # 标签转换成惯用的(0，1)分类\ny_test = y_test - 1 # 标签转换成惯用的(0，1)分类\nprint (X_train) # 打印训练集中的特征\nprint (y_train) # 打印训练集中的标签","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:04:21.355223Z","iopub.execute_input":"2024-02-09T15:04:21.355602Z","iopub.status.idle":"2024-02-09T15:04:21.406691Z","shell.execute_reply.started":"2024-02-09T15:04:21.355572Z","shell.execute_reply":"2024-02-09T15:04:21.405452Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train = np.expand_dims(X_train, axis=2) # 张量升阶，以满足序列数据集的要求\nX_test = np.expand_dims(X_test, axis=2) # 张量升阶，以满足序列数据集的要求","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:04:31.970364Z","iopub.execute_input":"2024-02-09T15:04:31.971244Z","iopub.status.idle":"2024-02-09T15:04:31.975453Z","shell.execute_reply.started":"2024-02-09T15:04:31.971210Z","shell.execute_reply":"2024-02-09T15:04:31.974512Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.models import Sequential # 导入序贯模型\nfrom keras import layers # 导入所有类型的层\nfrom tensorflow.keras.optimizers import Adam # 导入优化器\nimport tensorflow as tf\nmodel = Sequential() # 序贯模型\nmodel.add(layers.Conv1D(32, kernel_size=10, strides=4,\n          input_shape=(3197, 1))) # 1D CNN层\nmodel.add(layers.MaxPooling1D(pool_size=4, strides=2)) # 池化层\nmodel.add(layers.GRU(256, return_sequences=True)) # 关键，GRU层够要大\nmodel.add(layers.Flatten()) # 展平\nmodel.add(layers.Dropout(0.5)) # Dropout层\nmodel.add(layers.BatchNormalization()) # 批标准化   \nmodel.add(layers.Dense(1, activation='sigmoid')) # 分类输出层\nopt = tf.keras.optimizers.legacy.Adam(learning_rate=0.0001, beta_1=0.9, beta_2=0.999, decay=0.01) # 设置优化器\nmodel.compile(optimizer=opt, # 优化器\n              loss = 'binary_crossentropy', # 交叉熵\n              metrics=['accuracy']) # 准确率","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:04:36.104324Z","iopub.execute_input":"2024-02-09T15:04:36.105264Z","iopub.status.idle":"2024-02-09T15:04:51.396842Z","shell.execute_reply.started":"2024-02-09T15:04:36.105221Z","shell.execute_reply":"2024-02-09T15:04:51.395841Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"history = model.fit(X_train,y_train, # 训练集\n                    validation_split = 0.2, # 部分训练集数据拆分成验证集\n                    batch_size = 128, # 批量大小\n                    epochs = 4, # 训练轮次\n                    shuffle = True) # 乱序","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:04:58.405383Z","iopub.execute_input":"2024-02-09T15:04:58.405755Z","iopub.status.idle":"2024-02-09T15:05:12.300298Z","shell.execute_reply.started":"2024-02-09T15:04:58.405726Z","shell.execute_reply":"2024-02-09T15:05:12.299389Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import classification_report # 分类报告\nfrom sklearn.metrics import confusion_matrix # 混淆矩阵\ny_prob = model.predict(X_test) # 对测试集进行预测\ny_pred =  np.where(y_prob > 0.5, 1, 0) #将概率值转换成真值\ncm = confusion_matrix(y_pred, y_test)\nprint('Confusion matrix:\\n', cm, '\\n')\nprint(classification_report(y_pred, y_test))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:05:24.050892Z","iopub.execute_input":"2024-02-09T15:05:24.051539Z","iopub.status.idle":"2024-02-09T15:05:24.973556Z","shell.execute_reply.started":"2024-02-09T15:05:24.051501Z","shell.execute_reply":"2024-02-09T15:05:24.972639Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for i in range(len(y_prob)):\n    if y_prob[i] >= 0.5: \n        y_pred[i] = 1\n    else:\n        y_pred[i] = 0","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:06:02.924799Z","iopub.execute_input":"2024-02-09T15:06:02.925460Z","iopub.status.idle":"2024-02-09T15:06:02.932499Z","shell.execute_reply.started":"2024-02-09T15:06:02.925426Z","shell.execute_reply":"2024-02-09T15:06:02.931538Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"y_pred =  np.where(y_prob > 0.15, 1, 0) # 进行阈值调整\ncm = confusion_matrix(y_pred, y_test) \nprint('Confusion matrix:\\n', cm, '\\n')\nprint(classification_report(y_pred, y_test))","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:06:04.619617Z","iopub.execute_input":"2024-02-09T15:06:04.620634Z","iopub.status.idle":"2024-02-09T15:06:04.637211Z","shell.execute_reply.started":"2024-02-09T15:06:04.620580Z","shell.execute_reply":"2024-02-09T15:06:04.636281Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  通过API构建更灵活的模型","metadata":{}},{"cell_type":"code","source":"from keras import layers # 导入各种层\nfrom keras.models import Model # 导入模型\nfrom tensorflow.keras.optimizers import Adam # 导入Adam优化器\ninput = layers.Input(shape=(3197, 1)) # Input\n# 通过函数式API构建模型\nx = layers.Conv1D(32, kernel_size=10, strides=4)(input)\nx = layers.MaxPooling1D(pool_size=4, strides=2)(x)\nx = layers.GRU(256, return_sequences=True)(x)\nx = layers.Flatten()(x)\nx = layers.Dropout(0.5)(x)\nx = layers.BatchNormalization()(x)\noutput = layers.Dense(1, activation='sigmoid')(x) # Output\nmodel = Model(input, output) \nmodel.summary() # 显示模型的输出\nopt = tf.keras.optimizers.legacy.Adam(learning_rate=0.0001, beta_1=0.9, beta_2=0.999, decay=0.01) # 设置优化器\nmodel.compile(optimizer=opt, # 优化器\n              loss = 'binary_crossentropy', # 交叉熵\n              metrics=['accuracy']) # 准确率","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:08:01.201485Z","iopub.execute_input":"2024-02-09T15:08:01.201871Z","iopub.status.idle":"2024-02-09T15:08:01.528853Z","shell.execute_reply.started":"2024-02-09T15:08:01.201844Z","shell.execute_reply":"2024-02-09T15:08:01.527964Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 构建正向网络\ninput_1 = layers.Input(shape=(3197, 1))\nx = layers.GRU(32, return_sequences=True)(input_1)\nx = layers.Flatten()(x)\nx = layers.Dropout(0.5)(x)\n# 构建逆向网络\ninput_2 = layers.Input(shape=(3197, 1))\ny = layers.GRU(32, return_sequences=True)(input_2)\ny = layers.Flatten()(y)\ny = layers.Dropout(0.5)(y)\n# 连接两个网络\nz = layers.concatenate([x, y])\noutput = layers.Dense(1, activation='sigmoid')(z)\nmodel = Model([input_1,input_2], output)\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:08:03.932171Z","iopub.execute_input":"2024-02-09T15:08:03.932664Z","iopub.status.idle":"2024-02-09T15:08:04.457823Z","shell.execute_reply.started":"2024-02-09T15:08:03.932627Z","shell.execute_reply":"2024-02-09T15:08:04.453421Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# QUORA","metadata":{}},{"cell_type":"code","source":"df_train = pd.read_csv('/kaggle/input/quora-insincere-questions-classification/train.csv')\ndf_test = pd.read_csv('/kaggle/input/quora-insincere-questions-classification/test.csv')","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:09:42.366377Z","iopub.execute_input":"2024-02-09T15:09:42.367228Z","iopub.status.idle":"2024-02-09T15:09:47.501189Z","shell.execute_reply.started":"2024-02-09T15:09:42.367183Z","shell.execute_reply":"2024-02-09T15:09:47.500379Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.preprocessing.text import Tokenizer # 导入分词工具\nX_train_lst = df_train[\"question_text\"].values[0:10000] # 将评论读入张量（训练集）\nX_test_lst  = df_test[\"question_text\"].values # 将评论读入张量（测试集）\nX_test_ids  =  df_test[\"qid\"].values # 将ID读入张量（测试集）\ny_train = df_train[\"target\"].values[0:10000] # 构建标签集\ndictionary_size = 20000 # 设定词典的大小\ntokenizer = Tokenizer(num_words=dictionary_size) # 初始化词典\ntokenizer.fit_on_texts( X_train_lst ) # 使用训练集创建词典索引\n# 为所有训练集和测试集的所有评论的单词分配索引值，完成分词工作\nX_train_tokenized_lst = tokenizer.texts_to_sequences(X_train_lst)\nX_test_tokenized_lst  = tokenizer.texts_to_sequences(X_test_lst) ","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:09:49.397461Z","iopub.execute_input":"2024-02-09T15:09:49.398291Z","iopub.status.idle":"2024-02-09T15:09:56.412937Z","shell.execute_reply.started":"2024-02-09T15:09:49.398259Z","shell.execute_reply":"2024-02-09T15:09:56.412122Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt # 导入matplotlib\nword_per_comment = [len(comment) for comment in X_train_tokenized_lst]\nplt.hist(word_per_comment, bins = np.arange(0,100,10)) # 评论长度分布\nplt.show() ","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:10:16.160225Z","iopub.execute_input":"2024-02-09T15:10:16.161066Z","iopub.status.idle":"2024-02-09T15:10:16.346222Z","shell.execute_reply.started":"2024-02-09T15:10:16.161032Z","shell.execute_reply":"2024-02-09T15:10:16.345379Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.preprocessing.sequence import pad_sequences \nmax_comment_length = 100 # 设定评论输入长度为100，并填充默认值(如字数少于100)\nX_train = pad_sequences(X_train_tokenized_lst, maxlen=max_comment_length)\nX_test =  pad_sequences(X_test_tokenized_lst, maxlen=max_comment_length )","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:10:03.963146Z","iopub.execute_input":"2024-02-09T15:10:03.964056Z","iopub.status.idle":"2024-02-09T15:10:05.758559Z","shell.execute_reply.started":"2024-02-09T15:10:03.964010Z","shell.execute_reply":"2024-02-09T15:10:05.757534Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.models import Sequential # 导入贯序模型\nfrom keras.layers import Embedding #导入词嵌入层\nfrom keras.layers import Dense #导入全连接层\n# from keras.layers import CuDNNLSTM #导入CuDNNLSTM层\nfrom keras.layers import LSTM #导入LSTM层\nembedding_vecor_length = 60 # 设定词嵌入向量长度为60\nmodel = Sequential() # 贯序模型\nmodel.add(Embedding(dictionary_size, embedding_vecor_length, input_length=max_comment_length)) # 加入词嵌入\n# model.add(CuDNNLSTM(100)) # 加入CuDNNLSTM层\nmodel.add(LSTM(100)) # 加入CuDNNLSTM层\nmodel.add(Dense(10, activation='relu')) # 加入全连接层\nmodel.add(Dense(1, activation='sigmoid')) # 加入分类输出层\nmodel.compile(loss='binary_crossentropy', #损失函数\n              optimizer='adam', # 优化器\n              metrics=['accuracy']) # 评估指标\nprint(model.summary()) #打印网络模型","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:10:29.388956Z","iopub.execute_input":"2024-02-09T15:10:29.389782Z","iopub.status.idle":"2024-02-09T15:10:29.700082Z","shell.execute_reply.started":"2024-02-09T15:10:29.389730Z","shell.execute_reply":"2024-02-09T15:10:29.699199Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"history = model.fit(X_train, y_train, # 指定训练集\n                    validation_split = 0.3, # 拆分验证集\n                    epochs=10, # 指定轮次\n                    batch_size=64) # 批量大小","metadata":{"execution":{"iopub.status.busy":"2024-02-09T15:10:32.743805Z","iopub.execute_input":"2024-02-09T15:10:32.744159Z","iopub.status.idle":"2024-02-09T15:11:09.329091Z","shell.execute_reply.started":"2024-02-09T15:10:32.744130Z","shell.execute_reply":"2024-02-09T15:11:09.328314Z"},"trusted":true},"outputs":[],"execution_count":null}]}