第一个教程中的 Tensorflow 模型无法按预期工作
Tensorflow model from very 1st tutorial doesnt work like expected
尝试通过教程开始学习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)
提前致谢!
Your CPU supports instructions that this TensorFlow binary was not
compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
This is just a warning, stating that you can compile from source and be able to use it.
至于你的模型,没问题,但如果你规范化输入,你将获得 70% 的准确率
train_images = train_images.astype('float32') / 255
test_images = test_images.astype('float32') / 255
您可以在此处找到更多相关信息
https://stats.stackexchange.com/questions/211436/why-normalize-images-by-subtracting-datasets-image-mean-instead-of-the-current
尝试通过教程开始学习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)
提前致谢!
Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA This is just a warning, stating that you can compile from source and be able to use it.
至于你的模型,没问题,但如果你规范化输入,你将获得 70% 的准确率
train_images = train_images.astype('float32') / 255
test_images = test_images.astype('float32') / 255
您可以在此处找到更多相关信息 https://stats.stackexchange.com/questions/211436/why-normalize-images-by-subtracting-datasets-image-mean-instead-of-the-current