I have post the issue to tensorflow and keras-team.Cause the can't reproduce the issu, they suggest I post the issue to apple team.
I'm using MacBook Air with M1 chip. OS version is Big Sur 11.4.
which python
/Users/dmitry/Applications/Miniforge3/bin/python
I run the following code using tensorflow-macos and tensorflow_macos, respectively.
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10)
])
predictions = model(x_train[:1]).numpy()
tf.nn.softmax(predictions).numpy()
loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
loss_fn(y_train[:1], predictions).numpy()
model.compile(optimizer = 'sgd', loss = loss_fn)
model.fit(x_train, y_train, epochs=100)
I got this! with tensorflow-macos and python3.9:
Epoch 1/100
1875/1875 [==============================] - 8s 4ms/step - loss: 0.7026
Epoch 2/100
1875/1875 [==============================] - 8s 4ms/step - loss: 0.3872
Epoch 3/100
1875/1875 [==============================] - 8s 4ms/step - loss: 0.3284
Epoch 4/100
1875/1875 [==============================] - 8s 4ms/step - loss: 0.2891
Epoch 5/100
1875/1875 [==============================] - 8s 4ms/step - loss: 0.2622
with tensorflow_macos and python3.8 env:
Epoch 1/100
1875/1875 [==============================] - 1s 276us/step - loss: 1.2181
Epoch 2/100
1875/1875 [==============================] - 1s 270us/step - loss: 0.4678
Epoch 3/100
1875/1875 [==============================] - 1s 269us/step - loss: 0.3935
Epoch 4/100
1875/1875 [==============================] - 1s 271us/step - loss: 0.3507
Epoch 5/100
1875/1875 [==============================] - 1s 270us/step - loss: 0.3231
Why tensorflow-macos is so slower than tensorflow_macos?Did I miss something?