artificial-intelligence - 神经网络是否只能解决具有 0..1 个输入值和 0..1 个预期输出值的问题?

标签 artificial-intelligence neural-network

我刚刚创建了我的第一个神经网络,它使用梯度方法和反向传播学习算法。它使用双曲正切作为激活函数。代码经过了很好的单元测试,所以我对网络实际工作充满了美好的希望。然后我决定创建一个集成测试并尝试教我的网络解决一些非常简单的功能。基本上,我正在测试权重是否有所改善(只有一个,因为这是一个非常小的网络 - 输入加一个神经元)。

    // Combinations of negative sign for values greater than 1
    [TestCase(8, 4)] // FAIL reason 1
    [TestCase(-8, 4)] // FAIL reason 1
    [TestCase(8, -4)] // FAIL reason 1
    [TestCase(-8, -4)] // FAIL reason 1
    // Combinations of negative sign for values lesser than 1
    [TestCase(.8, .4)] // OK
    [TestCase(-.8, .4)] // FAIL reason 2
    [TestCase(.8, -.4)] // FAIL reason 2
    [TestCase(-.8, -.4)] // OK
    // Combinations of negative sign for one value greater than 1 and the other value lesser than 1
    [TestCase(-.8, 4)] // FAIL reason 2
    [TestCase(8, -.4)] // FAIL reason 2
    // Combinations of one value greater than 1 and the other value lesser than 1
    [TestCase(.8, 4)] // OK
    [TestCase(8, .4)] // FAIL reason 1
    public void ShouldImproveLearnDataSetWithNegativeExpectedValues(double expectedOutput, double x)
    {
        var sut = _netBuilder.Build(1, 1); // one input, only one layer with one output
        sut.NetSpeedCoefficient = .9;

        for (int i = 0; i < 400; i++)
        {
            sut.Feed(new[] { x }, new[] { expectedOutput });
        }

        var postFeedOutput = sut.Ask(new[] { x }).First();
        var postFeedDifference = Math.Abs(postFeedOutput - expectedOutput);
        postFeedOutput.Should().NotBe(double.NaN);
        postFeedDifference.Should().BeLessThan(1e-5);
    }

我很失望,因为大部分测试用例都失败了(只有 3 个标有'//OK'的通过)。我深入研究了代码并发现了一些有趣的事实。

  1. 双曲正切最大值为 1。因此无论权重 * 输入之和有多大,神经元的输出绝对值将始终 <= 1。换句话说,网络永远不会学习求解一个函数,如果它是返回绝对值大于 1。这解释了具有 8,-8 预期输出的测试用例的所有失败。
  2. 在其中一个数字为负数的测试用例中,最终权重也应为负数。首先它会减少,但它永远不会变成负数。它要么在 0 附近停止,要么在 0 附近来回跳跃。

神经网络是否只能解决具有 0..1 个输入值和 0..1 个预期输出值的问题,还是我的实现有问题?

最佳答案

您可以从 NN 获得其他输出。如果你想要离散输出(分类),使用Softmax Regression .相反,如果你想要连续输出(回归),那么你必须在输出范围(最小值,最大值)和(0,1)之间创建一个双射映射。在大多数情况下,映射 f:(min,max)->(0,1), f(x) = (x-min)/(max-min) 就足够了。

In test cases where one of the numbers is negative the final weight should also be negative

为什么最终权重也应该是负数?

您可以将任何数字作为输入。 (尽管将特征归一化到更小的范围是一种很好的做法,通常是使它们具有均值 0 和标准差 1)

关于artificial-intelligence - 神经网络是否只能解决具有 0..1 个输入值和 0..1 个预期输出值的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24854709/

相关文章:

artificial-intelligence - 你想解决哪些优化问题?

machine-learning - 我需要标准化神经网络的目标吗?

java - 帮助 Neuroph 神经网络

python - 在 Keras 中实现 LSTM

artificial-intelligence - JASON (AgentSpeak) 如何使用带有变量的外部操作

machine-learning - 如何向神经网络添加更多输出?

.net - NLP/任务。回答-从数据库检索信息

python - 神经网络识别手写数字: Dealing with multiple outputs

python - Tensorflow cnn 错误 : logits and labels must be same size:

python - 神经网络 - 检查节点激活