Keras神经网络.前处理 [英] Keras Neural Network. Preprocessing

查看:82
本文介绍了Keras神经网络.前处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将神经网络适合于回归问题时,我对此表示怀疑.我使用来自 sklearn.preprocessing Imputers Scale 的方法对火车和测试数据的预测变量(特征)进行了预处理,但我没有预处理了我的火车数据或测试数据的类或目标.

I have this doubt when I fit a neural network in a regression problem. I preprocessed the predictors (features) of my train and test data using the methods of Imputers and Scale from sklearn.preprocessing,but I did not preprocessed the class or target of my train data or test data.

在我的神经网络的体系结构中,除最后一层具有 Sigmoid 功能外,所有层均具有 relu 作为激活功能.我为最后一层选择了S型函数,因为预测值在0到1之间.

In the architecture of my neural network all the layers has relu as activation function except the last layer that has the sigmoid function. I have choosen the sigmoid function for the last layer because the values of the predictions are between 0 and 1.

tl; dr:总之,我的问题是:我应该对神经网络的输出进行处理吗?如果我不使用S形函数,则我的输出值为<. 0和>1.在这种情况下,我该怎么办?

tl;dr: In summary, my question is: should I deprocess the output of my neuralnet? If I don't use the sigmoid function, the values of my output are < 0 and > 1. In this case, how should I do it?

谢谢

推荐答案

通常,如果要进行回归,则应在最后一层使用线性激活. S型函数会偏爱"更接近0和1的值,因此模型很难输出中间值.

Usually, if you are doing regression you should use a linear' activation in the last layer. A sigmoid function will 'favor' values closer to 0 and 1, so it would be harder for your model to output intermediate values.

如果目标的分布是高斯分布或均匀分布,我将使用线性输出层.除非您有非常大的目标,否则不需要进行预处理.

If the distribution of your targets is gaussian or uniform I would go with a linear output layer. De-processing shouldn't be necessary unless you have very large targets.

这篇关于Keras神经网络.前处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆