操作系统: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.
我忘了什么吗
请参考工作代码为MNIST数据集培训CNN
(操作系统:windows 10、TensorFlow:2.0.0和Keras:2.2.4)
相关问题 更多 >
编程相关推荐