Python variable initialization


I am trying to initialize the value of x_train, but getting following error:

NameError: name 'X_train' is not defined

Here is code:

X_train = X_train.astype(‘float32’)
X_test = X_test.astype(‘float32’)
X_train /= 255
X_test /= 255


There is the undefined variable that your code is assigning.


I want to use it in future, just want to initialize it.


But you haven’t, as the error message indicates. X_train is undefined, so does not have an astype method. This will raise a 'NoneType` related error.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.