我正在尝试使用该neuralnet
软件包在 R 中训练一个神经网络。我正在运行回归模型并尝试预测计数变量“Rented_Bike_Count”。我混合了分类变量和数值变量,并通过model.matrix
.
我已将数据转换为 model.matrix 并删除了截距项。我读过与这个问题类似的问题,每个人都说要降低学习率。它似乎根本没有帮助,我不相信我需要让我的学习率小到1e-6
.
还有什么问题?我怎样才能解决这个问题?我尝试使用threshold=0.5
它似乎可以工作,但我真的不明白为什么。
代码:
library(caret)
library(neuralnet)
sigmoid <- function(x) 1 / (1+exp(-x))
# must make our factor variables in to a one-hot encoding (binary form)
X_train <- model.matrix(~., data = Train_set_standardized)[,-1] # remove intercept term
dimnames(X_train)
Train_nn_sigmoid <- neuralnet(Rented_Bike_Count~.,
data = X_train,
hidden = 1,
learningrate = 1e-6,
act.fct = sigmoid,
linear.output = TRUE, # FALSE Means output node gets the activation function
threshold = 0.5,
err.fct = "sse")
Error in if (reached.threshold < min.reached.threshold) { :
missing value where TRUE/FALSE needed