我收到错误"nnet.default(x,y,w,...)中的错误:权重过多(77031)"在训练神经网络时 [英] I get error "Error in nnet.default(x, y, w, ...) : too many (77031) weights" while training neural networks

查看:64
本文介绍了我收到错误"nnet.default(x,y,w,...)中的错误:权重过多(77031)"在训练神经网络时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用软件包 nnet 在R中训练神经网络.以下是有关我的训练数据的信息.

I am trying to train neural networks in R using package nnet. Following is the information about my training data.

str(traindata)

'data.frame':   10327 obs. of  196 variables:
$ stars                          : num  5 5 5 3.5 3.5 4.5 3.5 5 5 3.5 ...
$ open                           : num  1 1 1 1 1 1 1 1 1 1 ...
$ city                           : Factor w/ 61 levels "ahwatukee","anthem",..: 36 38
$ review_count                   : int  3 5 4 5 14 6 21 4 14 10 ...
$ name                           : Factor w/ 8204 levels " leftys barber shop",..:
$ longitude                      : num  -112 -112 -112 -112 -112 ...
$ latitude                       : num  33.6 33.6 33.5 33.4 33.7 ...
$ greek                          : int  0 0 0 0 0 0 0 0 0 0 ...
$ breakfast...brunch             : int  0 0 0 0 0 0 0 0 0 0 ...
$ soup                           : int  0 0 0 0 0 0 0 0 0 0 ...

我已将这些信息删节了.

I have truncated this information.

当我运行以下命令时:

library(nnet)  
m4 <- nnet(stars~.,data=traindata,size=10, maxit=1000)

我收到以下错误:

Error in nnet.default(x, y, w, ...) : too many (84581) weights

当我尝试更改参数的权重时,例如:

When I try changing weights in the argument like:

m4 <- nnet(stars~.,data=traindata,size=10, maxit=1000,weights=1000)

然后我得到以下错误:

Error in model.frame.default(formula = stars ~ ., data = traindata, weights = 1000) : 
variable lengths differ (found for '(weights)')

我犯的错误是什么?如何避免或纠正此错误?也许问题出在我对重量"的理解上.

What is the mistake I am making? How do I avoid or correct this error? Maybe the problem is with my understanding of "weights".

推荐答案

要么将 MaxNWts 增大到可以容纳模型大小的水平,要么减小 size 即可您的模型较小.

Either increase MaxNWts to something that will accommodate the size of your model, or reduce size to make your model smaller.

您可能还想进一步考虑要在模型中包括哪些变量.仅查看所提供的数据, name 是一个包含8000多个级别的因素.仅使用10000个观测值,您就不会从中得到任何明智的选择. city 可能会更有用,但同样,像神经网络这样复杂的东西中的61个级别可能还很有限.

You probably also want to think some more on exactly which variables to include in the model. Just looking at the data provided, name is a factor with more than 8000 levels; you're not going to get anything sensible out of it with only 10000 observations. city might be more useful, but again, 61 levels in something as complex as a neural net is likely to be marginal.

这篇关于我收到错误"nnet.default(x,y,w,...)中的错误:权重过多(77031)"在训练神经网络时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆