我尝试编写一个神经网络,该网络在我从 Aurelion Geron 的 GitHup 获得的加利福尼亚住房数据集上进行训练。但是当我运行代码时,网络没有得到训练并且 loss = nan。有人可以解释我做错了什么吗?最好的问候,罗宾
csv 文件的链接:https://github.com/ageron/handson-ml/tree/master/datasets/housing
我的代码:
import numpy
import pandas as pd
from keras.models import Sequential
from keras.layers import Dense
# load dataset
df = pd.read_csv("housing.csv", delimiter=",", header=0)
# split into input (X) and output (Y) variables
Y = df["median_house_value"].values
X = df.drop("median_house_value", axis=1)
# Inland / Not Inland -> True / False = 1 / 0
X["ocean_proximity"] = X["ocean_proximity"]== "INLAND"
X=X.values
X= X.astype(float)
Y= Y.astype(float)
model = Sequential()
model.add(Dense(100, activation="relu", input_dim=9))
model.add(Dense(1, activation="linear"))
# Compile model
model.compile(loss="mean_squared_error", optimizer="adam")
model.fit(X, Y, epochs=50, batch_size=1000, verbose=1)
我发现了错误,“total_bedrooms”列中缺少一个值
我是一名优秀的程序员,十分优秀!