gpt4 book ai didi

r - 为什么在 R 的 deepnet 包中使用 nn.predict 进行预测会返回常量值?

转载 作者:行者123 更新时间:2023-12-02 04:48:49 24 4
gpt4 key购买 nike

我与 The CIFAR-10 dataset 一起工作.这是我准备数据的方式:

library(R.matlab)
A1 <- readMat("data_batch_1.mat")
A2 <- readMat("data_batch_2.mat")
A3 <- readMat("data_batch_3.mat")
A4 <- readMat("data_batch_4.mat")
A5 <- readMat("data_batch_5.mat")
meta <- readMat("batches.meta.mat")
test <- readMat("test_batch.mat")
A <- rbind(A1$data, A2$data, A3$data, A4$data, A5$data)
Gtrain <- 0.21*A[,1:1024] + 0.71*A[,1025:2048] +0.07*A[,2049:3072]
ytrain <- c(A1$labels, A2$labels, A3$labels, A4$labels, A5$labels)
Gtest <- 0.21*test$data[,1:1024] + 0.71*test$data[,1025:2048] +0.07*test$data[,2049:3072]
ytest <- test$labels
x_train <- Gtrain[ytrain %in% c(7,9),]
y_train <- ytrain[ytrain %in% c(7,9)]==7
x_test <- Gtest[ytest %in% c(7,9),]
y_test <- ytest[ytest %in% c(7,9)]==7

我训练深度神经网络:

library(deepnet)
dnn <- dbn.dnn.train(x_train, y_train, hidden = rep(10,2),numepochs = 3)

然后我做出预测

prednn <- nn.predict(dnn, x_test)

返回填充有一个值的向量(在本例中为 0.4603409,但对于不同的参数,它始终约为 0.5)。怎么了?

最佳答案

基于对类似问题的回答,可以考虑这种方法: neuralnet prediction returns the same values for all predictions

The first reason to consider when you get weird results with neural networks is normalization. Your data must be normalized, otherwise, yes, the training will result in skewed NN which will produce the same outcome all the time, it is a common symptom.

Looking at your data set, there are values >>1 which means they are all treated by NN essentially the same. The reason for it is that the traditionally used response functions are (almost) constant outside some range around 0.

Always normalize your data before feeding it into a neural network.

关于r - 为什么在 R 的 deepnet 包中使用 nn.predict 进行预测会返回常量值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30617755/

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