【发布时间】:2020-06-22 12:52:00
【问题描述】:
操作系统:Windows 10 TensorFlow:2.0.0 Keras:2.2.4
我正在尝试为 MNIST 数据集训练 CNN。我使用 python-mnist 模块加载数据集。 当我尝试运行代码时,它会在纪元开始之前卡住。 我的代码:
from mnist import MNIST
import tensorflow as tf
from tensorflow import keras
mndata=MNIST('data')
train_images,train_labels=mndata.load_training()
test_images,test_labels=mndata.load_testing()
model= keras.Sequential([
keras.layers.Input(shape=784),
keras.layers.Dense(256,activation='relu'),
keras.layers.Dense(64,activation='relu'),
keras.layers.Dense(10,activation='softmax')
])
model.compile(optimizer='adam',loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(train_images,train_labels, validation_split = 0.2,epochs=50)
test_loss, test_accuracy= model.evaluate(test_images, test_labels)
print('Accuracy=', test_accuracy)
model.save('NetworkModel.h5')
我的输出:
2020-03-10 08:10:18.061068: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations: AVX AVX2
To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags.
2020-03-10 08:10:18.069858: I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 4. Tune using inter_op_parallelism_threads for best performance.
我是不是忘记了什么?
【问题讨论】:
标签: python tensorflow keras deep-learning mnist