Tensorflow RNN-like neural network on Mac M1 does not work expectly

https://www.tensorflow.org/tutorials/load_data/text

I try some tutorials of Tensorflow official site on my macbook air m1 to learn tensorflow, find RNN-like neural network does not work as expected, such as RNN, GRU, LSTM. Later I run the same code on my linux server, it works properly.

I can't figure it out. It maybe a bug of tensorflow-macos or tensorflow-metal.

The result of my mac:

100/100 [==============================] - 33s 273ms/step - loss: 9.6882 - accuracy: 0.2562 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 2/10
100/100 [==============================] - 25s 250ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 3/10
100/100 [==============================] - 25s 252ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 4/10
100/100 [==============================] - 25s 254ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 5/10
100/100 [==============================] - 25s 255ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 6/10
100/100 [==============================] - 26s 256ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 7/10
100/100 [==============================] - 26s 257ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 8/10
100/100 [==============================] - 26s 258ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 9/10
100/100 [==============================] - 26s 258ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587
Epoch 10/10
100/100 [==============================] - 26s 256ms/step - loss: 12.1238 - accuracy: 0.2478 - val_loss: 11.9475 - val_accuracy: 0.2587

Like not train at all. If it is four classification problems, the accuracy would around 0.25, and binary classification problem 0.5.

My platform:

tensorflow-macos v2.10

tensorflow-metal v0.6.0

mac-os v12.6.3

mac-air m1

I tried the official version tensorflow of official website, it works as expected.

conda install tensorflow

Because the official version only support CPU, I suspect is the GPU problem of tensorflow-macos. Tried only use CPU on tensorflow-macos with

with tf.device('/cpu:0'):

It also work as expected.

Suspect the bug of the GPU on tensorflow-macos cause it can't prosses RNN-like model.

Tensorflow RNN-like neural network on Mac M1 does not work expectly
 
 
Q