Im using the given code example on the fashion_mnist dataset. It contains metrics="accuracy" and runs through. Whenever I change it to metrics=tf.keras.metrics.Accuracy() it gives me following error:
ValueError: Shapes (32, 10) and (32, 1) are incompatible
What am i doing wrong? Is the Accuracy() function not the same?
import tensorflow as tf
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
train_images = train_images / 255.
test_images = test_images / 255.
model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation=tf.keras.activations.relu),
tf.keras.layers.Dense(10)])
model.compile(
optimizer=tf.keras.optimizers.Adam(),
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy'])
model.fit(train_images, train_labels, epochs=10)