简体   繁体   English

r Neuronet软件包—多个输出

[英]r neuralnet package — multiple output

The way I am currently using neural net is that it predicts one output point from many input points. 我目前使用神经网络的方式是,它可以从许多输入点预测一个输出点。 More specifically, I run the below. 更具体地说,我运行以下内容。

nn <- neuralnet(
as.formula(a ~ c + d),
data=Z, hidden=c(3,2), err.fct="sse", act.fct=custom,
linear.output=TRUE, rep=5)

Here, if Z is a matrix of columns with names a, b, c, it will predict one point from one row in column a from the corresponding points in rows c and d. 在这里,如果Z是名称为a,b,c的列的矩阵,则它将根据c和d行中的对应点从a列中的一行预测一个点。 (The vertical dimension is used as samples for training.) (垂直尺寸用作训练样本。)

Suppose there's also a column b. 假设还有一列b。 I am wondering if there's a way to predict both, a and b, from c and d? 我想知道是否有一种方法可以从c和d预测a和b? I've tried 我试过了

as.formula(a+b ~ c+d)

but that does not appear to work. 但这似乎不起作用。

Any ideas? 有任何想法吗?

My bad, it works nicely using a + b ~ c + d. 我不好,使用a + b〜c + d效果很好。 I thought the function did not accept this input (as it crashed many times), but there must have been another problem which is now gone that I cleaned it all up. 我以为函数不接受此输入(因为它多次崩溃),但是肯定还有另一个问题消失了,我将其全部清除了。

nn <- neuralnet(as.formula(a + b ~ c + d),
                data=Z, hidden=c(3,2), err.fct="sse", act.fct=custom,
                linear.output=TRUE, rep=5)

Works beautifully and returns two point (or two column) output! 运行精美,并返回两点(或两列)输出! Neat. 整齐。


Examples from neuralnet , the format works :) 来自neuralnet示例,格式有效:)

 AND <- c(rep(0,7),1)
 OR <- c(0,rep(1,7))
 binary.data <- data.frame(expand.grid(c(0,1), c(0,1), c(0,1)), AND, OR)
 print(net <- neuralnet(AND+OR~Var1+Var2+Var3,  binary.data, hidden=0, 
         rep=10, err.fct="ce", linear.output=FALSE))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM