调整神经网络的大小参数?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (309)

我想用卡特软件包来拟合一个神经网络模型。有208个预测变量,所有这些变量都很重要,不能丢弃。我可以给size参数的最大值是4,超过这个值我会得到一个错误,说明权重太多。

> ctrl<-trainControl(method = 'cv',number = 5)
> my.grid <- expand.grid(.decay = 0.1, .size =5)
> nn.fit <- train(train_predictors,train_responses[["r2c1"]],method = "nnet",algorithm = 'backprop', tuneGrid = my.grid,trace=F, linout = TRUE,trControl = ctrl)
Something is wrong; all the RMSE metric values are missing:
      RMSE        Rsquared        MAE     
 Min.   : NA   Min.   : NA   Min.   : NA  
 1st Qu.: NA   1st Qu.: NA   1st Qu.: NA  
 Median : NA   Median : NA   Median : NA  
 Mean   :NaN   Mean   :NaN   Mean   :NaN  
 3rd Qu.: NA   3rd Qu.: NA   3rd Qu.: NA  
 Max.   : NA   Max.   : NA   Max.   : NA  
 NA's   :1     NA's   :1     NA's   :1    
Error: Stopping
In addition: Warning messages:
1: model fit failed for Fold1: decay=0.1, size=5 Error in nnet.default(x, y, w, ...) : too many (1051) weights

2: model fit failed for Fold2: decay=0.1, size=5 Error in nnet.default(x, y, w, ...) : too many (1051) weights

3: model fit failed for Fold3: decay=0.1, size=5 Error in nnet.default(x, y, w, ...) : too many (1051) weights

4: model fit failed for Fold4: decay=0.1, size=5 Error in nnet.default(x, y, w, ...) : too many (1051) weights

5: model fit failed for Fold5: decay=0.1, size=5 Error in nnet.default(x, y, w, ...) : too many (1051) weights

6: In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo,  :
  There were missing values in resampled performance measures.

该模型对4个神经元(大小= 4)表现非常差。如果我想要超过5个神经元,我该怎么做才能使模型起作用?

提问于
用户回答回答于

这里是我使用mxnet进行adam nn的示例:

mxnet_grid_A2 = expand.grid(layer1 = c(10, 12),   
                           layer2 = c(4, 6),
                           layer3 = 2,
                           learningrate = c(0.001, 0.0001),
                           dropout = c(0, 0.2)
                           beta1 = .9,
                           beta2 = 0.999,
                           activation = 'relu')
用户回答回答于

你始终可以使用caret train方法中的可选参数将其他参数传递给底层的训练方法(在这种情况下nnet)。nnet软件包的CRAN文档描述了MaxNwts允许控制最大隐藏单元数量的参数。

扫码关注云+社区

领取腾讯云代金券