简体   繁体   English

如何使用我的keras TensorFlow模型减少损失?

[英]How can I reduce loss with my keras TensorFlow model?

So I have a dataset of about 140,000 samples with 5 inputs, the velocity of the car, the acceleration of the car, the velocity of the lead car gathered with radar, the distance of the lead car, and the acceleration of the lead car. 因此,我有一个大约140,000个样本的数据集,其中有5个输入,汽车的速度,汽车的加速度,领先汽车的雷达速度,领头车的距离以及领头车的加速度。 The output is from 0 to 1, 0 being maximum brake, and 1 being max acceleration. 输出从0到1,0最大制动,1是最大加速。

I'm a beginner to neural nets, so I'm having trouble optimizing my model to get the best accuracy/loss for this data. 我是神经网络的初学者,所以我无法优化我的模型以获得这些数据的最佳准确度/损失。 I've been experimenting with changing the optimizer, activation function, number of hidden layers, number of nodes in the layers, etc but nothing seems to be lowering the loss over time. 我一直在尝试更改优化器,激活功能,隐藏层数,层中节点数等,但似乎没有什么能够降低一段时间内的损失。

Here's my current model: 这是我目前的型号:

opt = keras.optimizers.Adam(lr=0.001, decay=1e-6)
model = Sequential()
model.add(Dense(5, activation="tanh", input_shape=(x_train.shape[1:])))
for i in range(40):
    model.add(Dense(60, activation="relu"))
model.add(Dense(1))

I'm not too worried about overfitting my data right now as I can work on that later, I'm just trying to basically memorize the data to see how low I can get the loss, just to see if I can improve it. 我现在不太担心过度拟合我的数据,因为我可以稍后再努力,我只是想基本记住数据,看看我能获得多少损失,只是为了看看我是否可以改进它。 And predict on data that was trained to make sure it can return the correct output. 并预测经过培训的数据,以确保它能够返回正确的输出。 However the lowest I've gotten the validation loss is around 0.015 , which definitely isn't returning the current output in my tests, it's about 90% accurate. 然而,我得到的最低验证损失约为0.015 ,这绝对不会在我的测试中返回当前输出,它的准确率约为90%。

Is there anything I'm doing wrong? 有什么我做错了吗? Should I be increasing my model size, or decreasing it? 我应该增加我的模型大小,还是减少它? Nothing I've tried seems to be working. 我尝试过的任何东西似乎都没有用。 I've also made sure to normalize my 5 inputs and 1 output independently. 我还确保将我的5个输入和1个输出正常化。 It seems it never learns anything after a few epochs. 似乎它在几个时代之后永远不会学到任何东西。

Thanks if anyone decides to help me on this very specific problem. 谢谢,如果有人决定帮我解决这个非常具体的问题。

I'd like to help but there's not too much info there. 我想帮忙,但那里没有太多的信息。

First what's the aim of the network? 首先,网络的目标是什么? It's hard to tell what you're trying to reduce the loss of . 这很难说,你想减少损失什么。 What's your loss function? 你的损失功能是什么? What are your labels? 你的标签是什么? This seems like a classic reinforcement learning question, rather than a traditional supervised learning problem. 这似乎是一个经典的强化学习问题,而不是传统的监督学习问题。 How's the data structured? 数据结构如何? I'm assuming they're "runs" with some sort of score? 我假设他们以某种得分“跑”了?

A blanket thing, that's probably too many layers. 一个毯子的东西,这可能是太多的层次。

Most of the time with networks the biggest improvement comes with cleaning your data (which we'll assume is fine) and messing with your loss function. 大部分时间使用网络最大的改进来自清理数据(我们认为这很好)并且弄乱你的损失功能。 It's best to start with a simple model and figure out if you need more. 最好先从一个简单的模型开始,然后弄清楚是否需要更多。

There's also this, which is reinforcement learning, but it's a good example https://github.com/lexfridman/deeptraffic 还有这个,这是强化学习,但它是一个很好的例子https://github.com/lexfridman/deeptraffic

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

相关问题 如何使用 tensorflow 损失 function 与 keras Z20F35E630DAF44DBDFA4C3F68F539? - How do I use a tensorflow loss function with a keras model? 如何为 keras model 使用 tensorflow 自定义损失? - How to use tensorflow custom loss for a keras model? 如何在自定义Keras / Tensorflow Loss函数中对值进行排序? - How can I sort the values in a custom Keras / Tensorflow Loss Function? 如何在 Keras model 的自定义损失中访问张量的内容 - How can I access to content of Tensor in custom loss of Keras model 在 Tensorflow 中,如何在计算损失时访问模型的权重? - In Tensorflow, how can I access my model's weights when computing loss? 如何在 Keras model 中使用加权 MSE 作为损失 function? - How can I use a weighted MSE as loss function in a Keras model? 如何提高精度并减少我的 model 的损失 - How to improve accuracy and reduce loss of my model 如何使用 tensorflow 和 keras 加快我的 model 训练过程 - How can i speed up my model training process using tensorflow and keras 仅当验证准确性提高时,我如何才能保存/覆盖我的 TensorFlow/Keras 模型? - How can I save/overwrite my TensorFlow/Keras model ONLY when validation accuracy improves? 如何 model.predict 内部损失 function? (张量流,Keras) - How to model.predict inside loss function? (Tensorflow, Keras)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM