Python TLearn - 损失太高

Python TFlearn - Loss too high

在解决我的输入形状问题后 运行 我的程序,问题是程序打印的总损失太高了(如果我将它与快速入门中的相比)教程)。

我的目标是通过使用过去的数据预测未来入口的拥堵(我有超过 10M 的入口和标记的分数)所以我应该不会有训练问题。

这是我的代码:

import numpy as np
import tflearn

# Load CSV file, indicate that the first column represents labels
from tflearn.data_utils import load_csv
data, labels = load_csv('nowcastScaled.csv', has_header=True, n_classes=2)

# Preprocessing function
def preprocess(data):
    return np.array(data, dtype=np.float32)

# Preprocess data
data = preprocess(data)

# Build neural network
net = tflearn.input_data(shape=[None, 2])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='linear')
data = np.reshape(data, (-1, 2))
labels = np.reshape(labels, (-1, 2))
net = tflearn.regression(net, optimizer='adam', learning_rate=0.001,
                         loss='categorical_crossentropy')

# Define model
model = tflearn.DNN(net)
# Start training (apply gradient descent algorithm)
model.fit(data, labels, n_epoch=15, batch_size=16, show_metric=True)

# Training
model.save('test_Model')
model.load('test_Model')
score = model.evaluate(data, labels, batch_size=16)

我的 excel 文件具有这种外观(2 列,100 000 法分)

calculed_at , congestion
1 , 56
2 , 21

结果如下(15 个纪元):

Training samples: 50000
Validation samples: 0
....
--
Training Step: 40625  | total loss: 15.27961 | time: 17.659s
| Adam | epoch: 013 | loss: 15.27961 - acc: 0.7070 -- iter: 50000/50000
--
Training Step: 43750  | total loss: 15.66268 | time: 17.549s
| Adam | epoch: 014 | loss: 15.66268 - acc: 0.7247 -- iter: 50000/50000
--
Training Step: 46875  | total loss: 15.94696 | time: 18.037s
| Adam | epoch: 015 | loss: 15.94696 - acc: 0.7581 -- iter: 50000/50000
--

您知道什么会导致如此高的损失吗?看起来 st运行ge 因为打印的准确性似乎还不错。感谢您的帮助。

编辑:这似乎是我采用这些值的好时机,因为当我刚才尝试时我的总损失超过 280(精度低于 0,3 或略高于)。

对于时间序列,您通过考虑时间帧 window 来构造 input/output 个样本。在每个 window 中,如果样本是 {0, 1, ...N} select,则第一个 N-1 个样本作为输入,最后一个样本作为输出。然后你可以做回归做 time prediction.