在R中运行神经网络时出错(神经元中的错误[[i]]%*%权重[[i]]:需要数字/复数矩阵/向量参数)

在R中运行神经网络时出错(神经元中的错误[[i]]%*%权重[[i]]:需要数字/复数矩阵/向量参数),r,neural-network,R,Neural Network,我尝试使用R中的neuralnet库在自行车共享数据集上运行神经网络。我尝试运行的代码是: nn <- neuralnet(Bike_Count~., data=train, hidden=2, act.fct = "tanh", linear.output = FALSE) 我的数据的可复制样本如下所示: structure(list(Bike_Count = structure(c(2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L

我尝试使用R中的neuralnet库在自行车共享数据集上运行神经网络。我尝试运行的代码是:

nn <- neuralnet(Bike_Count~., data=train, hidden=2, act.fct = "tanh", linear.output = FALSE)
我的数据的可复制样本如下所示:

   structure(list(Bike_Count = structure(c(2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L), .Label = c("0", "1"), class = "factor"), Holiday = structure(c(2L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", "1"), class = "factor"), 
    Hour = structure(c(13L, 13L, 3L, 20L, 21L, 24L, 1L, 23L, 
    1L, 11L), .Label = c("0", "1", "2", "3", "4", "5", "6", "7", 
    "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", 
    "18", "19", "20", "21", "22", "23"), class = "factor"), Temperature..C. = c(22.1, 
    32.6, 13.1, 19.2, 33.9, 4.1, 24.7, 25.1, 16.7, 25.5), Humidity = c(67, 
    51, 73, 55, 58, 46, 94, 73, 50, 33)), row.names = c(3637L, 
5557L, 3843L, 3140L, 5877L, 8448L, 6529L, 5183L, 7201L, 4403L
), class = "data.frame")
另外,我试着只使用数字变量运行模型,它运行得很好,但我想在其中包括“小时”和“假日”功能


非常感谢你的帮助

这回答了你的问题吗?我认为你的问题是重复的;
   structure(list(Bike_Count = structure(c(2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L), .Label = c("0", "1"), class = "factor"), Holiday = structure(c(2L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", "1"), class = "factor"), 
    Hour = structure(c(13L, 13L, 3L, 20L, 21L, 24L, 1L, 23L, 
    1L, 11L), .Label = c("0", "1", "2", "3", "4", "5", "6", "7", 
    "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", 
    "18", "19", "20", "21", "22", "23"), class = "factor"), Temperature..C. = c(22.1, 
    32.6, 13.1, 19.2, 33.9, 4.1, 24.7, 25.1, 16.7, 25.5), Humidity = c(67, 
    51, 73, 55, 58, 46, 94, 73, 50, 33)), row.names = c(3637L, 
5557L, 3843L, 3140L, 5877L, 8448L, 6529L, 5183L, 7201L, 4403L
), class = "data.frame")