楼主: dcfyb1990
6314 2

[问答] r语言建立bp错误提示 REAL() can only be applied to a 'numeric', not a [推广有奖]

  • 0关注
  • 0粉丝

初中生

66%

还不是VIP/贵宾

-

威望
0
论坛币
1 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
82 点
帖子
5
精华
0
在线时间
30 小时
注册时间
2015-9-16
最后登录
2019-4-22

楼主
dcfyb1990 发表于 2016-3-17 09:08:07 |AI写论文
1论坛币
麻烦各位大神帮帮忙~在用r软件建立bp神经网络时遇到问题~
r语言源代码为:
建立bp网络:
net <- newff(n.neurons=c(50,8,2,1), learning.rate.global=1e-2, momentum.global=0.5,
        error.criterium="LMS", Stao=NA, hidden.layer="tansig",
        output.layer="purelin", method="ADAPTgdwm")
(1)训练bp网络
result <- train(net, trainset[,-51],trainset$y, error.criterium="LMS", report=TRUE, show.step=100, n.shows=5 )
错误提示:
Error in train.method(net, P, T, show.step, n.threads = n.threads) :
  REAL() can only be applied to a 'numeric', not a 'character'
(2)采用x=matrix(as.numeric(x),nrow=nrow(x))语句想将字符型改为数字型出现错误提示:
Error in matrix(as.numeric(x), nrow = nrow(x)) :   (list) object cannot be coerced to type 'double'
(3)模型之前想对数据进行标准化用语句
scale(x, scale = TRUE)出现错误提示:Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric。







关键词:numeric Applied ONLY 错误提示 Real Error character 源代码 method report

沙发
dcfyb1990 发表于 2016-3-17 11:15:29
原来是x的格式是list,要先转换格式后在标准化
x=matrix(unlist(x),nrow=nrow(x))
x=scale(x, scale = TRUE)
index = 1:nrow(x)#行数
testindex = sample(index, trunc(length(index)/3))#抽样的过程,抽取测试集的行号,从index中抽取约1/3的样本,trunc()向零取整
testset = x[testindex, ]#testset测试集
trainset = x[-testindex, ]#trainset训练集
net <- newff(n.neurons=c(50,8,2,1), learning.rate.global=1e-2, momentum.global=0.5,
        error.criterium="LMS", Stao=NA, hidden.layer="tansig",
        output.layer="purelin", method="ADAPTgdwm")

result <- train(net, trainset[,-51],trainset[,51], error.criterium="LMS", report=TRUE, show.step=100, n.shows=5 )

藤椅
爽爽胖胖 学生认证  发表于 2016-10-9 22:01:06
net <- newff(n.neurons=c(50,8,2,1), learning.rate.global=1e-2, momentum.global=0.5,
        error.criterium="LMS", Stao=NA, hidden.layer="tansig",
        output.layer="purelin", method="ADAPTgdwm")

result <- train(net, trainset[,-51],trainset[,51], error.criterium="LMS", report=TRUE, show.step=100, n.shows=5 )
后面这是什么意思?

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 14:25