Help Center/ ModelArts/ Troubleshooting/ Training Jobs/ Service Code Issues/ Error Message "AttributeError: 'NoneType' object has no attribute 'dtype'" Displayed in Logs
Updated on 2023-01-17 GMT+08:00

Error Message "AttributeError: 'NoneType' object has no attribute 'dtype'" Displayed in Logs

Symptom

Code can run properly in the notebook Keras image. When tensorflow.keras is used for training, error message "AttributeError: 'NoneType' object has no attribute 'dtype'" is displayed.

Possible Causes

The NumPy version of the training image is different from that in the notebook instance.

Solution

Print the NumPy version in the code and check whether the version is 1.18.5. If the version is not 1.18.5, run the following command at the beginning of the code:

import os
os.system('pip install numpy==1.18.5')

If the error persists, modify the preceding code as follows:

import os
os.system('pip install numpy==1.18.5')
os.system('pip install keras==2.6.0')
os.system('pip install tensorflow==2.6.0')