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