Python variable initialization


#1

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


#2

There is the undefined variable that your code is assigning.


#3

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


#4

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.


#5

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