我正在使用Rstudio进行一些网络分析,并使用mxnet库研究GAN以进行网络分析,然后执行以下代码:
mx.gan <-
function(data,
label,
hidden_nodeG = 1,
hidden_nodeD = 1,
out_nodeG = 1,
out_nodeD = 1,
activationG = "tanh",
activationD = "tanh",
out_activationG = "softmax",
out_activationD = "softmax")
{
act <- mx.symbol.Variable("data")
m <- length(hidden_nodeG)
if (length(activationG) == 1) {
activationG <- rep(activationG, m)
} else {
if (length(activationG) != m) {
stop(paste("Length of activationG should be",m))
}
}
if (length(activationD) == 1) {
activationD <- rep(activationD, m)
} else {
if (length(activationD) != m) {
stop(paste("Length of activationD should be",m))
}
}
#GENERATOR
for (i in seq_len(m)) {
fc <- mx.symbol.FullyConnected(act, num_hidden=hidden_nodeG[i])
act <- mx.symbol.Activation(fc, act_type=activationG[i])
}
fc <- mx.symbol.FullyConnected(act, num_hidden=out_nodeG)
out <- switch(out_activationG,
"rmse" = mx.symbol.LinearRegressionOutput(fc),
"softmax" = mx.symbol.SoftmaxOutput(fc),
"logistic" = mx.symbol.LogisticRegressionOutput(fc),
stop("Not supported yet."))
G_sym <- mx.model.FeedForward.create(out, X=data, y=label, ctx = ctx)
#DISCRIMINATOR
act <- mx.symbol.Variable("data")
m <- length(hidden_nodeD)
for (i in seq_len(m)) {
fc <- mx.symbol.FullyConnected(act, num_hidden=hidden_nodeD[i])
act <- mx.symbol.Activation(fc, act_type=activationD[i])
}
fc <- mx.symbol.FullyConnected(act, num_hidden=out_nodeD)
out <- switch(out_activationD,
"rmse" = mx.symbol.LinearRegressionOutput(fc),
"softmax" = mx.symbol.SoftmaxOutput(fc),
"logistic" = mx.symbol.LogisticRegressionOutput(fc),
stop("Not supported yet."))
D_sym <- mx.model.FeedForward.create(out, X=data, y=label, ctx = ctx)
return(list(G_sym, D_sym))
}
在歧视者发表评论之前,我遇到了以下错误:
“ dimnames<-.data.frame
(*tmp*
中的错误,值= list(n)):
为数据框指定了无效的“假名”
从以下位置调用:dimnames<-.data.frame
(*tmp*
,值= list(n))“