Getting some issues related to tensorflow (2.5.0) on MacOS with M1 chip

I am trying the following text Classification code from François Chollet’s Deep Learning Book on MacOS BigSur M1 Chip (Version 11.2.3) for the first time. I am using tensorflow version 2.5.0

import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.datasets import imdb
from tensorflow.keras.preprocessing import sequence
max_features = 2000
max_len = 500
(x_train, y_train), (x_test, y_test) = imdb.load_data(num_words=max_features)
x_train = sequence.pad_sequences(x_train, maxlen=max_len)
x_test = sequence.pad_sequences(x_test, maxlen=max_len)
model = keras.models.Sequential()
model.add(layers.Embedding(max_features, 128,input_length=max_len,name='embed'))
model.add(layers.Conv1D(32, 7, activation='relu'))
model.add(layers.Conv1D(32, 7, activation='relu'))

history =, y_train, epochs=20, batch_size=128,

Why these accuracy and loss values are very high. I am getting different values, if I run the same code on Windows 10.

Results on MacOS:

Results on Windows 10:

Even running any other code, using Adam’s Optimizer, I am getting a notice that Kernel appears to have died.

Results on MacOS:

And how to avoid these warnings (in pink box)?

Please help!!

Hi @Syedaa,

Welcome to the Tensorflow Forum!

I tried replicating the same code in Mac OS(Ventura 13.5) with Python version 3.10 and Tensorflow 2.9 and found the good result. Please have a look at this attached replicated code gist. Could you please try again executing the same code with the latest tensorflow version and let us know if the issue still persists.

To avoid getting the warnings (W) or informational (I) messages while executing the code, please use below code on top of tensorflow import.

import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"

import tensorflow as tf