gpt4 book ai didi

R - 神经网络 - 传统的反向传播看起来很奇怪

转载 作者:行者123 更新时间:2023-12-01 02:00:29 25 4
gpt4 key购买 nike

我正在试验 neuralnet 中的不同算法包但是当我尝试传统的backprop算法结果非常奇怪/令人失望。几乎所有的计算结果都是~.33???我假设我必须错误地使用算法,就像我使用默认值 rprop+ 运行它一样它确实区分了样本。当然,正常的反向传播并没有那么糟糕,特别是如果它能够如此迅速地收敛到提供的阈值。

library(neuralnet)
data(infert)

set.seed(123)
fit <- neuralnet::neuralnet(formula = case~age+parity+induced+spontaneous,
data = infert, hidden = 3,
learningrate = 0.01,
algorithm = "backprop",
err.fct = "ce",
linear.output = FALSE,
lifesign = 'full',
lifesign.step = 100)

preds <- neuralnet::compute(fit, infert[,c("age","parity","induced","spontaneous")])$net.result

summary(preds)
V1
Min. :0.3347060
1st Qu.:0.3347158
Median :0.3347161
Mean :0.3347158
3rd Qu.:0.3347162
Max. :0.3347286

这里的某些设置应该不同吗?

示例默认神经网络
set.seed(123)
fit <- neuralnet::neuralnet(formula = case~age+parity+induced+spontaneous,
data = infert, hidden = 3,
err.fct = "ce",
linear.output = FALSE,
lifesign = 'full',
lifesign.step = 100)

preds <- neuralnet::compute(fit, infert[,c("age","parity","induced","spontaneous")])$net.result

summary(preds)
V1
Min. :0.1360947
1st Qu.:0.1516387
Median :0.1984035
Mean :0.3346734
3rd Qu.:0.4838288
Max. :1.0000000

最佳答案

建议您在输入神经网络之前对数据进行标准化。如果你这样做,那么你很高兴去:

library(neuralnet)
data(infert)

set.seed(123)
infert[,c('age','parity','induced','spontaneous')] <- scale(infert[,c('age','parity','induced','spontaneous')])
fit <- neuralnet::neuralnet(formula = case~age+parity+induced+spontaneous,
data = infert, hidden = 3,
learningrate = 0.01,
algorithm = "backprop",
err.fct = "ce",
linear.output = FALSE,
lifesign = 'full',
lifesign.step = 100)

preds <- neuralnet::compute(fit, infert[,c("age","parity","induced","spontaneous")])$net.result
summary(preds)
V1
Min. :0.02138785
1st Qu.:0.21002456
Median :0.21463423
Mean :0.33471568
3rd Qu.:0.47239818
Max. :0.97874839

实际上有一些关于 SO 处理这个的问题。 Why do we have to normalize the input for an artificial neural network? 似乎有一些最详细的信息。

关于R - 神经网络 - 传统的反向传播看起来很奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36846006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com