我的训练数据集对我的神经网络而言是否过于复杂? [英] Is my training data set too complex for my neural network?

查看:122
本文介绍了我的训练数据集对我的神经网络而言是否过于复杂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是机器学习和堆栈溢出的新手,我试图从我的回归模型中解释两个图.

I am new to machine learning and stack overflow, I am trying to interpret two graphs from my regression model.

我的机器学习模型中的训练错误和验证错误

我的情况类似于此人

my case is similar to this guy Very large loss values when training multiple regression model in Keras but my MSE and RMSE are very high.

我的建模不合身吗?如果是,我该怎么解决这个问题?

Is my modeling underfitting? if yes what can I do to solve this problem?

这是我用来解决回归问题的神经网络

Here is my neural network I used for solving a regression problem

def build_model():
model = keras.Sequential([
    layers.Dense(128, activation=tf.nn.relu, input_shape=[len(train_dataset.keys())]),
    layers.Dense(64, activation=tf.nn.relu),
    layers.Dense(1)
])
optimizer = tf.keras.optimizers.RMSprop(0.001)

model.compile(loss='mean_squared_error',
              optimizer=optimizer,
              metrics=['mean_absolute_error', 'mean_squared_error'])
return model

和我的数据集 我有500个样本,10个功能和1个目标

and my data set I have 500 samples, 10 features and 1 target

推荐答案

正好相反:您的模型看起来过拟合.如果您的训练集的错误率很低,则意味着您的模型已经从数据中很好地学习了,并且可以准确地推断出结果.但是,如果之后的验证数据很高,则意味着从训练数据中学到的信息不能成功地应用于新数据..这是因为您的模型过多地适合"了训练数据,并且仅了解如何根据这些数据很好地进行预测.

Quite the opposite: it looks like your model is over-fitting. When you have low error rates for your training set, it means that your model has learned from the data well and can infer the results accurately. If your validation data is high afterwards however, that means that the information learned from your training data is not successfully being applied to new data. This is because your model has 'fit' onto your training data too much, and only learned how to predict well when its based off of that data.

为解决此问题,我们可以引入常见解决方案以减少过度拟合.一种非常常见的技术是使用Dropout层.这将随机删除一些节点,以使模型不会与它们过分关联-从而减少了对这些节点的依赖性,并使用其他节点来学习"更多信息.我提供了一个示例,您可以在下面进行测试;尝试发挥价值和其他技巧,以找出最有效的方法.另外请注意:您确定在密集层中需要多个节点吗?似乎对您的数据集相当多,这也可能导致过拟合.

To solve this, we can introduce common solutions to reduce over-fitting. A very common technique is to use Dropout layers. This will randomly remove some of the nodes so that the model cannot correlate with them too heavily - therefor reducing dependency on those nodes and 'learning' more using the other nodes too. I've included an example that you can test below; try playing with the value and other techniques to see what works best. And as a side note: are you sure that you need that many nodes within your dense layer? Seems like quite a bit for your data set, and that may be contributing to the over-fitting as a result too.

def build_model():
model = keras.Sequential([
layers.Dense(128, activation=tf.nn.relu, input_shape=[len(train_dataset.keys())]),
Dropout(0.2),
layers.Dense(64, activation=tf.nn.relu),
layers.Dense(1)
])
optimizer = tf.keras.optimizers.RMSprop(0.001)

model.compile(loss='mean_squared_error',
          optimizer=optimizer,
          metrics=['mean_absolute_error', 'mean_squared_error'])
return model

这篇关于我的训练数据集对我的神经网络而言是否过于复杂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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