I am trying to train a neural network to control a characters speed in 2 dimensions. x and y between -1 and 1 m/sec. Currently I split the range into 0.1 m/sec intervals so I end up with 400 output neurons (20 x values * 20 y values) if I increase the accuracy to 0.01 I end up with 40k output neurons. Is there a way to reduce the number of output neurons?
问问题
219 次
1 回答
3
我假设您将问题视为分类问题。在训练的时候,你有输入X
和输出Y
。由于您正在训练神经网络进行分类,因此您的预期输出总是如下:
-1 -0.9 ... 0.3 0.4 0.5 ... 1.0 m/s
Y1 = [0, 0, ..., 1, 0, 0, ..., 0] // speed x component
Y2 = [0, 0, ..., 0, 0, 1, ..., 0] // speed y component
Y = [Y1, Y2]
即:对于x和y方向的每个速度分量,只有一个神经元输出1;所有其他神经元输出 0(在上面的示例中,此训练实例的预期输出在 x 方向为 0.3m/s,在 y 方向为 0.5m/s)。实际上这可能更容易学习并且具有更好的预测性能。但正如你所指出的,它不能扩展。
我认为您也可以将问题视为回归问题。在您的网络中,每个速度分量都有一个神经元。您的预期输出只是:
Y = [0.3, 0.5] // for the same training instance you have.
要获得 -1 到 1 的输出范围,输出层中的激活函数有不同的选项。例如,您可以使用
f(x) = 2 * (Sigmoid(x) - 0.5)
Sigmoid(x) = 1 / (1 + exp(-x))
由于sigmoid (x) 在 (0,1) 中,所以 2*(sigmoid(x) - 0.5) 在 (-1,1) 中。这种变化(用两个神经元替换输出层中的多个神经元)大大降低了模型的复杂性,因此您可能希望在中间层添加更多神经元以避免拟合不足。
于 2014-09-15T07:55:05.807 回答