代码之家  ›  专栏  ›  技术社区  ›  Josh Korn

反向传播公式似乎无法实现

  •  0
  • Josh Korn  · 技术社区  · 9 年前

    公式如下:

    enter image description here

    delta-layer2=(Theta-layer2转置)x delta-layer3点x gprime(--现在不重要)

    工作代码如下所示:

    % d3 is delta3, d2 is delta2, Theta2 is minus the bias column
    % dimensions: d3--[5000x10], d2--[5000x25], Theta2--[10x25]
    
    d3 = (a3 - y2);
    d2 = (d3 * Theta2) .* gPrime(z2);
    

    1. 工作代码反转表达式第一部分中的术语;
    2. 工作代码不会转置Theta-layer2,但公式会转置。

    乔希

    1 回复  |  直到 9 年前
        1
  •  2
  •   user3666197    9 年前

    首先,我们必须做一些简化。

    1° 我们将只使用 in_Data vector in_Data[N] (在以下N=2的情况下)(如果我们仅在pat中成功,则不难将其扩展到矩阵中)。

    2° this blog )

    enter image description here

    enter image description here

    M=num_pattern ,但我们有以前的声明 in_data 作为向量,所以你可以 删除上面公式中的总和和下面公式中的矩阵

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    让我们编写代码:(我真的不懂MATLAB,所以我将编写一个伪代码)

    vector d[num_connections+num_output_neurons]  // num derivatives = num connections whitout count bias there are 8 connections. ;  +2 derivative of O)
    vector z[num_neurons]     // z is the output of each neuron.
    vector w[num_connections] // Yes a Vector! we have previous removed matrix and the sum.
    
    // O layer
    d[10] = (a[O1] - y[O1]);   // Start from last to calculate the error. 
    d[9] = (a[O2] - y[O2]);  
    
    // H -> O layer
    for i=5; i<=8; i++ ( Hidden to Out layer connections){
        d[i] = (d)*g_prime(z[i])
    }
    
    // I -> H layer
    
     for i=1; i<=8 i++ (Input to Hidden layer connections){
    
         for j=1; i<=num_connection_from_neuron i++ (Take for example d[1] it depends on how many connections have H1 versus Outputs){
         d[i] = d1 + (d[j+4]*w[j+4] )
    
         }
      d[i] = d[i]*g_prime(z[i]);
    }
    

    如果您需要在矩阵中扩展它,请在注释中编写它,我将扩展代码。

    祝你好运,马可。

    推荐文章