简体   繁体   English

为什么我的预测 model 每次运行时都会给出不同的预测结果?

[英]Why does my prediction model keep giving a different prediction result every time I run it?

I have built a stock prediction model using LSTM.我使用 LSTM 构建了一个股票预测 model。 however, everytime when I run the program, the value of RMSE and the prediction result keep changing ( I did not change any data in the program. It giving out different result everytime when I clicking the run buttom everytime, ) Can anyone let me know what is the reason of it.但是,每次运行程序时,RMSE的值和预测结果都会不断变化(我没有更改程序中的任何数据。每次单击运行按钮时都会给出不同的结果,)谁能告诉我这是什么原因。 Thank you very much非常感谢

I will suggest you know more about layers and some other basic things of neural networks.我会建议你更多地了解神经网络的层和其他一些基本知识。

How does a neural network learn?神经网络是如何学习的?

A neural network contains three types of layers.神经网络包含三种类型的层。 Input, output, and hidden layers.输入、output 和隐藏层。 All these layers contain neurons or you can say nodes.所有这些层都包含神经元,或者你可以说节点。 Every layer's neurons are connected with it's previous and next layer's neurons.每一层的神经元都与它的上一层和下一层的神经元相连。 Take a look at the picture below.看看下面的图片。 在此处输入图像描述

You can call the connections 'path'.您可以将连接称为“路径”。 Every path has some weights value.每条路径都有一些权重值。 A neuron's input value is calculated by summing all the multiplications of outputs of previous layer's neuron and the path's weight value.神经元的输入值是通过将前一层神经元的所有输出乘积与路径的权重值相加来计算的。 Then the sum value is processed by some activation function.然后通过一些激活 function 处理总和值。 You can learn more about it by joining online classes or from tutorials.您可以通过加入在线课程或教程来了解更多信息。

But my point is, prediction completely depends on those weights.但我的观点是,预测完全取决于这些权重。 And those weights value keeps changing depending on the learning rate and some other stuff during training.这些权重值会根据训练期间的学习率和其他一些东西不断变化。 What about the very beginning?最开始呢? at epoch no.在纪元号1? 1? Basically model generates some random weights for all the paths.基本上 model 为所有路径生成一些随机权重。 Then keeps changing those values during training to minimize the loss.然后在训练期间不断改变这些值以最小化损失。

Every time you run your train, it generates random values.每次运行火车时,它都会生成随机值。 That's why you get different results each time.这就是为什么你每次都会得到不同的结果。 If you fix those values using tf.seed or some other method, you will get reproducible results.如果您使用 tf.seed 或其他方法修复这些值,您将获得可重现的结果。 btw, you don't need to train every time.顺便说一句,你不需要每次都训练。 Save your model weights, then load it whenever you need to predict.保存您的 model 权重,然后在需要预测时加载它。 You will get the same result every time you load the model weights and use that model to predict.每次加载 model 权重并使用该 model 进行预测时,都会得到相同的结果。

There are many sources of randomness in machine learning (described in link below).机器学习中有许多随机性来源(在下面的链接中描述)。 https://machinelearningmastery.com/randomness-in-machine-learning/ https://machinelearningmastery.com/randomness-in-machine-learning/

In this case it may probably be "Randomness in the Algorithm" even if you make sure to apply exactly same data in same order.在这种情况下,即使您确保以相同的顺序应用完全相同的数据,它也可能是“算法中的随机性”。

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

相关问题 Tensorflow回归模型每次给出相同的预测 - Tensorflow regression model giving same prediction every time 为什么我的模型每次训练都会给出不同的结果? - Why is my model giving different result each time I train it? Keras VGG16 修改后的 model 每次都给出相同的预测 - Keras VGG16 modified model giving the same prediction every time 我的预测 model 预测正确吗? - Does my prediction model predict the right thing? 根据预测,我加载的模型给了我一个 AttributeError - Upon prediction, my loaded model is giving me an AttributeError 为什么机器学习 model 每次都给出不同的准确率值? - Why does machine learning model keep on giving different accuracy values each time? 为什么使用标准缩放器时,我的 model 的预测在缩放数据和未缩放数据之间会发生变化? - Why does the prediction of my model change between scaled and unscaled data when using standard scaler? DNN model 的时间序列预测 - 预测的形状与窗口数据集中的训练标签不匹配 - Time Series Prediction of DNN model - shape of prediction does not match with trained labels in windowed dataset 时间序列预测 | 训练 Model - Time Series Prediction | Training the Model 为什么使用相同的 Keras 模型和输入进行预测会得到不同的结果? - Why am I getting different results on a prediction using the same Keras model and input?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM