神经网络中的错误(步骤< stepmax&& reach.threshold>阈值)

时间:2017-10-10 11:40:11

标签: r neural-network

我试图训练神经网络来执行两个数字的乘法运算。我不想使用规范化。我目前在RStudio上使用R包neuralnet。我的完整相关代码如下:

library(neuralnet)

# creating dataset
dataSize = 1000
datain <- data.frame(x1 = sample(1:dataSize) , x2 = sample(1:dataSize))
datain$y = datain$x1 * datain$x2

# splitting into train (80%) and test (20%) data
a = floor((0.8) * (dataSize)) 
dtrain <- datain[1:a , ] 
dtest <- datain[(a + 1):(dataSize) , ]  

# creating custom ReLU activation function
myActFunc = function(x) 
{
  log(1+exp(x))
}

#training NN 
a <- as.formula(paste("y ~ x1 + x2"))
f <- as.formula((a))

nn <- neuralnet(formula = f,
                data = as.matrix(dtrain),
                linear.output = TRUE,
                act.fct = myActFunc,
                hidden = c(4))

这会导致以下错误:

  

while时出错(步骤&lt; stepmax&amp;&amp; reach.threshold&gt;阈值){:
    缺少需要TRUE / FALSE的值

调整stepmax,learningrate和threshold参数会将错误更改为:

  

if(reach.threshold&lt; min.reached.threshold){:     缺少需要TRUE / FALSE的值

我找到了this question,我遇到了第二个错误,但没有回答。

请注意,这是回归问题,我不想使用规范化/缩放。

0 个答案:

没有答案