尝试通过教程开始学习tensorflow。从第一个开始(当然),由于某种原因,当我尝试学习模型时,它显示的损失数在10到12之间,准确度数在0.2到0.3之间,但教程中的数字却大不相同。在安装tensorflow遇到麻烦之前,我尝试使gpu可以工作,但是我只有错误,所以我仅在cpu支持下重新安装了它(python-tensorflow软件包archlinux)。但是我也遇到2019-02-22 19:18:02.042566: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
错误。我不知道是不是这样。
我的代码是:
import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation=tf.nn.relu),
keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(train_images, train_labels, epochs=5)
test_loss, test_acc = model.evaluate(test_images, test_labels)
print('Test accuracy:', test_acc)
谢谢!
答案 0 :(得分:1)
您的CPU支持此TensorFlow二进制文件未包含的指令 编译使用:SSE4.1 SSE4.2 AVX AVX2 FMA 这只是警告,表明您可以从源代码进行编译并可以使用它。
对于您的模型来说,可以,但是如果对输入进行归一化,您将获得70%的准确性
train_images = train_images.astype('float32') / 255
test_images = test_images.astype('float32') / 255