Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ValueError:无法在Python中将NumPy数组转换为张量(不支持的对象类型int)_Python_Pandas_Numpy_Keras_Neural Network - Fatal编程技术网

ValueError:无法在Python中将NumPy数组转换为张量(不支持的对象类型int)

ValueError:无法在Python中将NumPy数组转换为张量(不支持的对象类型int),python,pandas,numpy,keras,neural-network,Python,Pandas,Numpy,Keras,Neural Network,我已经为神经网络编写了以下代码,用于对数据集执行回归,但是我得到了一个ValueError。我查阅了不同的答案,他们建议使用df=df.values来获得numpy数组。我试过了,但还是产生了同样的错误。如何解决这个问题 代码 from keras import Sequential from keras.layers import Dense, Dropout, Flatten from keras.optimizers import Adam from sklearn.model_selec

我已经为神经网络编写了以下代码,用于对数据集执行回归,但是我得到了一个
ValueError
。我查阅了不同的答案,他们建议使用
df=df.values
来获得numpy数组。我试过了,但还是产生了同样的错误。如何解决这个问题

代码

from keras import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.optimizers import Adam
from sklearn.model_selection import train_test_split

#Define Features and Label
features = ['posted_by', 'under_construction', 'rera', 'bhk_no.', 'bhk_or_rk',
            'square_ft', 'ready_to_move', 'resale', 'longitude',
            'latitude'] 

X=train[features].values
y=train['target(price_in_lacs)'].values

#Train Test Split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state = 23, shuffle = True)

#Model
model = Sequential()
model.add(Dense(10, activation='relu', kernel_initializer='random_normal', input_dim = 10))
model.add(Dense(1, activation = 'relu', kernel_initializer='random_normal'))

#Compiling the neural network
model.compile(optimizer = Adam(learning_rate=0.1) ,loss='mean_squared_logarithmic_error', metrics =['mse'])

#Fitting the data to the training dataset  
model.fit(X_train,y_train, batch_size=256, epochs=100, verbose=0)
错误

ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int).

您使用的是哪种框架?是tensorflow keras吗?我使用keras@dishinghoyani,我在问题中添加了神经网络的导入。