我有一个包含 4 列的 CSV 文件。3 个输入和 1 个输出。已经正常化了。我可以使用 nnet 和神经网络来训练具有 3 个输入、3 个隐藏层、每个具有 3 个节点和一个输出的网络。有用。
我想对 MXNET 做同样的事情,但是在进行回归时,“FullyConected”的参数必须隐藏 = 1。任何其他值只会引发错误消息。
如何构建一个网络作为标题或此图像中的网络?
这是代码:
csvIn <- read.csv("normalized.csv")
require(mxnet)
inputData <- csvIn[,1:3]
outputData <- csvIn[,4]
lcinm <- data.matrix(inputData, rownames.force = "NA")
lcoutm <- data.matrix(outputData, rownames.force = "NA")
lcouta <- as.numeric(lcoutm)
data <- mx.symbol.Variable("data")
fc1 <- mx.symbol.FullyConnected(data, name="fc1", num_hidden=3)
act1 <- mx.symbol.Activation(fc1, name="sigm1", act_type="sigmoid")
fc2 <- mx.symbol.FullyConnected(act1, name="fc2", num_hidden=3)
act2 <- mx.symbol.Activation(fc2, name="sigm2", act_type="sigmoid")
fc3 <- mx.symbol.FullyConnected(act2, name="fc3", num_hidden=3)
softmax <- mx.symbol.LinearRegressionOutput(fc3, name="softmax")
mx.set.seed(0)
mxn <- mx.model.FeedForward.create(array.layout = "rowmajor", softmax, X = lcinm, y = lcouta, learning.rate=0.07, eval.metric=mx.metric.rmse)
这是错误消息:
Start training with 1 devices
[08:54:33] C:/Users/qkou/mxnet/dmlc-core/include/dmlc/logging.h:235: [08:54:33] src/ndarray/ndarray.cc:231: Check failed: from.shape() == to->shape() operands shape mismatch
Error in exec$update.arg.arrays(arg.arrays, match.name, skip.null) :
[08:54:33] src/ndarray/ndarray.cc:231: Check failed: from.shape() == to->shape() operands shape mismatch
输入数据(3 个节点)
> lcinm
INA INV INC
[1,] 0.327172792 0.1842063931 0.50227366
[2,] 0.328585645 0.1911366252 0.50394467
[3,] 0.329998499 0.1980668574 0.50557458
[4,] 0.333367019 0.1994041603 0.50606766
[5,] 0.338691205 0.2007416800 0.50656075
[6,] 0.344015391 0.2020789830 0.50705383
[7,] 0.345432095 0.2021049795 0.50698534
[8,] 0.346848798 0.2021309760 0.50691686
[9,] 0.348355970 0.2026784188 0.50617724
[10,] 0.349953611 0.2032256450 0.50542391
输出数据(1 个节点)
> lcouta
[1] 0.6334235 0.6336314 0.6338394 0.6339434 0.6339434 0.6339434
[7] 0.6306156 0.6272879 0.6241681 0.6212562 0.6183444 0.6170965