Using neuralnet with caret train and adjusting the

2019-02-15 18:11发布

So I've read a paper that had used neural networks to model out a dataset which is similar to a dataset I'm currently using. I have 160 descriptor variables that I want to model out for 160 cases (regression modelling). The paper I read used the following parameters:-

'For each split, a model was developed for each of the 10 individual train-test folds. A three layer back-propagation net with 33 input neurons and 16 hidden neurons was used with online weight updates, 0.25 learning rate, and 0.9 momentum. For each fold, learning was conducted from a total of 50 different random initial weight starting points and the network was allowed to iterate through learning epochs until the mean absolute error (MAE) for the validation set reached a minimum. '

Now they used a specialist software called Emergent in order to do this, which is a very specialised neuronal network model software. However, as I've done previous models before in R, I have to keep to it. So I'm using the caret train function in order to do 10 cross fold validation, 10 times with the neuralnet package. I did the following:-

cadets.nn <- train(RT..seconds.~., data = cadet, method = "neuralnet", algorithm = 'backprop', learningrate = 0.25, hidden = 3, trControl = ctrl, linout = TRUE)

I did this to try and tune the parameters as closely to the ones used in the paper, however I get the following error message:-

  layer1 layer2 layer3 RMSE Rsquared RMSESD RsquaredSD
1      1      0      0  NaN      NaN     NA         NA
2      3      0      0  NaN      NaN     NA         NA
3      5      0      0  NaN      NaN     NA         NA
Error in train.default(x, y, weights = w, ...) : 
  final tuning parameters could not be determined
In addition: There were 50 or more warnings (use warnings() to see the first 50)

Do you know what I'm doing wrong? It works when I do nnet, but I can't tune the parameters for that to make it similar to the ones used in the paper I'm trying to mimic.

This is what I get in the warnings() fifty times:-

1: In eval(expr, envir, enclos) :
  model fit failed for Fold01.Rep01: layer1=1, layer2=0, layer3=0 Error in neuralnet(form, data = data, hidden = nodes, ...) : 
  formal argument "hidden" matched by multiple actual arguments

2: In data.frame(..., check.names = FALSE) :
  row names were found from a short variable and have been discarded
3: In eval(expr, envir, enclos) :
  model fit failed for Fold01.Rep01: layer1=3, layer2=0, layer3=0 Error in neuralnet(form, data = data, hidden = nodes, ...) : 
  formal argument "hidden" matched by multiple actual arguments

4: In data.frame(..., check.names = FALSE) :
  row names were found from a short variable and have been discarded
5: In eval(expr, envir, enclos) :
  model fit failed for Fold01.Rep01: layer1=5, layer2=0, layer3=0 Error in neuralnet(form, data = data, hidden = nodes, ...) : 
  formal argument "hidden" matched by multiple actual arguments

Thanks!

1条回答
闹够了就滚
2楼-- · 2019-02-15 18:52

train sets hidden for you (based on the values given by layer-layer3. You are trying to specify that argument twice, hence:

formal argument "hidden" matched by multiple actual arguments

HTH,

Max

查看更多
登录 后发表回答