且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Keras:精度保持为零

更新时间:2023-12-02 22:22:52

据我所知,您正在尝试解决回归问题(浮点函数输出)而不是分类问题(一个热向量样式输出/输入)类别).

From what I can see you are trying to solve a regression problem (floating point function output) rather than a classification problem (one hot vector style output/put input into categories).

您的S形最终层只会提供0到1之间的输出,这显然限制了您的NN预测所需的Y值范围的能力,该范围会更高.您的NN试图尽可能地接近,但是您要限制它!输出层中的S形对于单类是"/否"输出是好的,但对回归没有好处.

Your sigmoid final layer will only give an output between 0 and 1, which clearly limits your NNs ability to predict the desired range of Y values which go up much higher. Your NN is trying to get as close as it can, but you are limiting it! Sigmoids in the output layer are good for single class yes/no output, but not regression.

因此,您希望最后一层具有线性激活,其中输入被求和.这样的东西,而不是乙状结肠. model.add(Dense(1, kernel_initializer='lecun_normal', activation='linear'))

So, you want your last layer to have a linear activation where the inputs are just summed. Something like this instead of the sigmoid. model.add(Dense(1, kernel_initializer='lecun_normal', activation='linear'))

那么至少在学习率足够低的情况下,它可能会起作用.

Then it will likely work, at least if the learning rate is low enough.

Google"keras回归"以获取有用的链接.

Google "keras regression" for useful links.