简体   繁体   English

Neural.network:不同输入的相同预测

[英]Neural network: same prediction for different inputs

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.我想使用 neural.network 预测值而不是 class。 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.我尝试使用较小的输入空间而不是 212207 进行调试,但这没有帮助。 The dataset is balanced and shuffled.数据集是平衡和混洗的。 Values of inputs range from 0 to 0.1 million.输入值的范围从 0 到 10 万。 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. output 的值从 -30 到 0 不等。我认为我在为回归神经网络定义 model 时犯了一些错误。 Can you please check if the code is correct?你能检查一下代码是否正确吗?

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:])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM