神经网络:不同输入的相同预测

发布于 01-22 21:56 字数 994 浏览 1 评论 0原文

对于不同输入,我得到了相同的预测。我正在尝试使用回归神经网络。我想预测值,而不是使用神经网络的类值。由于数据很大,因此我一次训练一个示例。这是我的代码的简化版本。

list_of_files= Path().cwd().glob("**/**/*S1D_A.fits") # create the list of file
model = Sequential()
model.add(Dense(10000, input_dim=212207, kernel_initializer='normal', activation='relu'))
model.add(Dense(100, activation='relu'))
model.add(Dense(1, kernel_initializer='normal'))
model.compile(loss='mean_squared_error', optimizer='adam')
for file_name in list_of_files:
    data=fits.getdata(file_name)
    X=data.flux 
    Y=data.rv
    #X is one input example with 212207 values/features
    #Y is one output value (float) 
    if i<6000000:         #out of 10000000
        model.fit(X.transpose(), Y, epochs=30, batch_size=1, verbose=0)
    else:
        prediction=model.predict(X.transpose())

我确保我正在培训不同的例子,并尝试在不同示例上进行预测。对于所有测试输入,我仍然获得相同的预测值。我尝试了一个较小的输入空间,而不是212207进行调试,但这无济于事。数据集是平衡和改组的。投入的值范围为0到100万。我还没有使他们归一化。输出的值从-30到0不等。 我认为我在定义回归神经网络模型时犯了一些错误。您能检查代码是否正确吗?

I am getting the same prediction for different inputs. I am trying to use a regressional neural network. I want to predict values instead of class using neural network. Since data is huge, I am training one example at a time. Here is a simplified version of my code.

list_of_files= Path().cwd().glob("**/**/*S1D_A.fits") # create the list of file
model = Sequential()
model.add(Dense(10000, input_dim=212207, kernel_initializer='normal', activation='relu'))
model.add(Dense(100, activation='relu'))
model.add(Dense(1, kernel_initializer='normal'))
model.compile(loss='mean_squared_error', optimizer='adam')
for file_name in list_of_files:
    data=fits.getdata(file_name)
    X=data.flux 
    Y=data.rv
    #X is one input example with 212207 values/features
    #Y is one output value (float) 
    if i<6000000:         #out of 10000000
        model.fit(X.transpose(), Y, epochs=30, batch_size=1, verbose=0)
    else:
        prediction=model.predict(X.transpose())

I made sure that I am training on different examples and trying predictions on different examples. I am still getting the same prediction value for all testing inputs. I tried a smaller input space instead of 212207 for debugging, but that did not help. The dataset is balanced and shuffled. Values of inputs range from 0 to 0.1 million. I haven't normalised them. values of output vary from -30 to 0.
I think I made some mistake in defining the model for regression neural network. Can you please check if the code is correct?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的背包2025-01-29 21:56:22

我认为您是要从数据集而不是整个数据集传递每个记录。现在,您可以预测与训练完全相同的数据。

这就是您要执行的:

model = Sequential()
model.add(Dense(10000, input_dim=212207, kernel_initializer='normal', activation='relu'))
model.add(Dense(100, activation='relu'))
model.add(Dense(1, kernel_initializer='normal'))
model.compile(loss='mean_squared_error', optimizer='adam')

X = X.transpose()

# train
model.fit(X[:6000000], Y, epochs=30, batch_size=1, verbose=0)

# test
prediction=model.predict(X[6000000:])

I think you meant to pass each record from dataset instead of whole dataset. Right now you predict on exactly same data as you train.

This is what you want to execute:

model = Sequential()
model.add(Dense(10000, input_dim=212207, kernel_initializer='normal', activation='relu'))
model.add(Dense(100, activation='relu'))
model.add(Dense(1, kernel_initializer='normal'))
model.compile(loss='mean_squared_error', optimizer='adam')

X = X.transpose()

# train
model.fit(X[:6000000], Y, epochs=30, batch_size=1, verbose=0)

# test
prediction=model.predict(X[6000000:])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文