如何在python中处理具有许多功能的LSTM? [英] How to handle LSTMs with many features in python?

查看:119
本文介绍了如何在python中处理具有许多功能的LSTM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个二进制分类问题.我使用以下keras模型进行分类.

I have a binary classification problem. I use the following keras model to do my classification.

input1 = Input(shape=(25,6))
x1 = LSTM(200)(input1)
input2 = Input(shape=(24,6))
x2 = LSTM(200)(input2)
input3 = Input(shape=(21,6))
x3 = LSTM(200)(input3)
input4 = Input(shape=(20,6))
x4 = LSTM(200)(input4)
x = concatenate([x1,x2,x3,x4])
x = Dropout(0.2)(x)
x = Dense(200)(x)
x = Dropout(0.2)(x)
output = Dense(1, activation='sigmoid')(x)

但是,我得到的结果非常糟糕.我以为原因是我的功能太多,因此concatenate之后的需求需要改进.
我也在考虑在concatenate之后使用flatten()层是否有帮助.
无论如何,由于我是深度学习的新手,所以我不确定如何使它成为一个更好的模型.

However, the results I get is extremely bad. I thought the reason is that I have too many features, thus, needs have more improved layers after the concatenate.
I was also thinking if it would be helpful to used a flatten() layer after the concatenate.
anyway, since I am new to deep learning, I am not so sure how to make this a better model.

如果需要,我很乐意提供更多详细信息.

I am happy to provide more details if needed.

推荐答案

这是我的建议

  1. 删除所有防止过度拟合的内容,例如Dropout和Regularizer.可能发生的情况是,您的模型可能无法使用给定的层来捕获数据的复杂性,因此您需要确保在添加正则化函数之前,模型能够首先过拟合.

  1. Remove every things that prevent overfitting, such as Dropout and regularizer. What can happen is that your model may not be able to capture the complexity of your data using given layer, so you need to make sure that your model is able to overfit first before adding regularizer.

现在尝试增加密集层数和每层神经元数,直到您看到一些改善为止.还有一种可能是您的数据太嘈杂,或者您只有很少的数据来训练模型,因此您甚至无法产生有用的预测.

Now try increase number of Dense layer and number of neuron in each layer until you can see some improvement. There is also a possibility that your data is too noisy or you have only few data to train the model so you can't even produce a useful predictions.

现在,如果您是 LUCKY ,并且可以看到过拟合,则可以添加Dropout和正则化器.

Now if you are LUCKY and you can see overfitting, you can add Dropout and regularizer.

由于每个神经网络都是基于梯度的算法,因此最终可能会达到局部最小值.您可能还需要以不同的初始权重多次运行该算法,然后才能获得良好的结果,或者可以更改损失函数,以解决局部最小值为全局最小值的凸问题.

Because every neural network is a gradient base algorithm, you may end up at local minimum. You may also need to run the algorithm multiple times with different initial weight before you can get a good result or You can change your loss function so that you have a convex problem where local minimum is global minimum.

如果您无法获得更好的结果

您可能需要尝试其他拓扑,因为LSTM只是试图对假定具有Markov属性的系统进行建模.您可以查看嵌套的LSTM或类似的东西,它们以下一个时间步长不仅仅取决于当前时间步长的方式对系统进行建模.

You may need to try different topology because LSTM is just trying to model a system that assume to have Markov property. you can look at nested-LSTM or something like that, which model the system in the way that next time step is not just depend on current time step.

这篇关于如何在python中处理具有许多功能的LSTM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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