x_train
在定义变量之前,可以使用变量两次.您需要先定义它,然后再使用它.
x_train = np.array(x_train).reshape(len(x_train), -1) # ^^^^^^^ ^^^^^^^ ^^^^^^^ # | | | # | +------------------------------------------------+ # | | You use x_train twice before it's ever defined | # | +------------------------------------------------+ # +------------------------------------------+ # | Your first definition of x_train is here | # +------------------------------------------+