Is this an incorrect way of back-propagating error with matrices? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsBack-propagation through max pooling layersDeriving backpropagation equations “natively” in tensor formGradients for bias terms in backpropagationCustom c++ LSTM slows down at 0.36 cost is usual?A good reference for the back propagation algorithm?GradientChecking, can I blame float precision?Synthetic Gradients - what's the practical benefit?Questions about Neural Network training (back propagation) in the book PRML (Pattern Recognition and Machine Learning)Purpose of backpropagation in neural networksHow can I perform backpropagation directly in matrix form?

/bin/ls sorts differently than just ls

Is there a verb for listening stealthily?

Why does BitLocker not use RSA?

What's the difference between using dependency injection with a container and using a service locator?

Married in secret, can marital status in passport be changed at a later date?

Etymology of 見舞い

Why aren't road bike wheels tiny?

What is the definining line between a helicopter and a drone a person can ride in?

Recursive calls to a function - why is the address of the parameter passed to it lowering with each call?

What documents does someone with a long-term visa need to travel to another Schengen country?

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

tabularx column has extra padding at right?

Marquee sign letters

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

How to make an animal which can only breed for a certain number of generations?

Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?

How to create a command for the "strange m" symbol in latex?

Why do C and C++ allow the expression (int) + 4*5?

Does traveling In The United States require a passport or can I use my green card if not a US citizen?

Will I be more secure with my own router behind my ISP's router?

Does Prince Arnaud cause someone holding the Princess to lose?

Is my guitar’s action too high?

Are Flameskulls resistant to magical piercing damage?

Who can become a wight?



Is this an incorrect way of back-propagating error with matrices?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsBack-propagation through max pooling layersDeriving backpropagation equations “natively” in tensor formGradients for bias terms in backpropagationCustom c++ LSTM slows down at 0.36 cost is usual?A good reference for the back propagation algorithm?GradientChecking, can I blame float precision?Synthetic Gradients - what's the practical benefit?Questions about Neural Network training (back propagation) in the book PRML (Pattern Recognition and Machine Learning)Purpose of backpropagation in neural networksHow can I perform backpropagation directly in matrix form?










0












$begingroup$


I was watching a public available video from Stanford (https://youtu.be/d14TUNcbn1k?t=2720) on the mathematics behind back propagation. They proposed a graph:



Graph 1



that was then used as an example of back propagation using matrices. (The red text is the back propagated gradient, the green is the forward pass vales). The final gradients found for the initial matrices (of $[[0.1,0.5],[-0.3,0.8]]$ and $[[0.2],[0.4]]$) is below:
enter image description here



I agree with the values for $x$, however, I don't quite understand how they achieved the values of $W$. The equation (see circled in red) is the equation they used for calculating the gradients for $W$:enter image description here



With this equation (where $q$ = [[0.22],[0.26]], I would think that for $W_1,2$ (which has a value of 0.5, and $i$ = 1 and $j$ = 2) would be equal to $2*q_1*x_2$, which in this case is $2*0.22*0.4 = 0.176$, which is not what they got.



Intuitively, I thought the values of $W$ would be exactly what they calculated, but with $0.104$ and $0.176$ swapped. The way I calculated it was taking the top value of $q$ as the gradient on $0.22$ (which it is), and therefor, as $0.22 = 0.1*0.2 + 0.5*0.4$, taking $fracpartial qpartial W_1,1=0.2$, and then multiplying this by $q_1$, I got $0.2*0.44=0.088$, which aligns with their calculations.



However, applying the same logic to $W_1,2$, I get $fracpartial qpartial W_1,2=0.4$, and multiplying this by $q_1$, $0.4*0.44=0.176$. This conflicts with their value of $0.104$. If this logic is continued, the matrix of gradients matches theirs exactly, aside from the $0.104$ and $0.176$ being swapped.



For clarity, I also drew out a graph and deconstructed the matrix multiplication into simplified multiplication of two different regular equations. See below for the graph (where the numbers above nodes/inputs represent their gradient):





(Sorry for bad hand writing and quality, there's a reason I submit all work using latex)



I suspect I am using incorrect notation for $W$, as in, $W_1,2$ doesn't actually represent $0.5$, but actually $-0.3$, but then that doesn't align with their provided example of how the matrix $[[0.22],[0.26]]$ was constructed (the equation describing $q= W cdot x = ...$), and also doesn't explain how I got the values for the graph I hand drew, as that doesn't rely on notation.



If you read all this and have any idea what I'm doing wrong I would very much appreciate your effort. Thankyou!










share|improve this question







New contributor




Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$
















    0












    $begingroup$


    I was watching a public available video from Stanford (https://youtu.be/d14TUNcbn1k?t=2720) on the mathematics behind back propagation. They proposed a graph:



    Graph 1



    that was then used as an example of back propagation using matrices. (The red text is the back propagated gradient, the green is the forward pass vales). The final gradients found for the initial matrices (of $[[0.1,0.5],[-0.3,0.8]]$ and $[[0.2],[0.4]]$) is below:
    enter image description here



    I agree with the values for $x$, however, I don't quite understand how they achieved the values of $W$. The equation (see circled in red) is the equation they used for calculating the gradients for $W$:enter image description here



    With this equation (where $q$ = [[0.22],[0.26]], I would think that for $W_1,2$ (which has a value of 0.5, and $i$ = 1 and $j$ = 2) would be equal to $2*q_1*x_2$, which in this case is $2*0.22*0.4 = 0.176$, which is not what they got.



    Intuitively, I thought the values of $W$ would be exactly what they calculated, but with $0.104$ and $0.176$ swapped. The way I calculated it was taking the top value of $q$ as the gradient on $0.22$ (which it is), and therefor, as $0.22 = 0.1*0.2 + 0.5*0.4$, taking $fracpartial qpartial W_1,1=0.2$, and then multiplying this by $q_1$, I got $0.2*0.44=0.088$, which aligns with their calculations.



    However, applying the same logic to $W_1,2$, I get $fracpartial qpartial W_1,2=0.4$, and multiplying this by $q_1$, $0.4*0.44=0.176$. This conflicts with their value of $0.104$. If this logic is continued, the matrix of gradients matches theirs exactly, aside from the $0.104$ and $0.176$ being swapped.



    For clarity, I also drew out a graph and deconstructed the matrix multiplication into simplified multiplication of two different regular equations. See below for the graph (where the numbers above nodes/inputs represent their gradient):





    (Sorry for bad hand writing and quality, there's a reason I submit all work using latex)



    I suspect I am using incorrect notation for $W$, as in, $W_1,2$ doesn't actually represent $0.5$, but actually $-0.3$, but then that doesn't align with their provided example of how the matrix $[[0.22],[0.26]]$ was constructed (the equation describing $q= W cdot x = ...$), and also doesn't explain how I got the values for the graph I hand drew, as that doesn't rely on notation.



    If you read all this and have any idea what I'm doing wrong I would very much appreciate your effort. Thankyou!










    share|improve this question







    New contributor




    Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      0












      0








      0





      $begingroup$


      I was watching a public available video from Stanford (https://youtu.be/d14TUNcbn1k?t=2720) on the mathematics behind back propagation. They proposed a graph:



      Graph 1



      that was then used as an example of back propagation using matrices. (The red text is the back propagated gradient, the green is the forward pass vales). The final gradients found for the initial matrices (of $[[0.1,0.5],[-0.3,0.8]]$ and $[[0.2],[0.4]]$) is below:
      enter image description here



      I agree with the values for $x$, however, I don't quite understand how they achieved the values of $W$. The equation (see circled in red) is the equation they used for calculating the gradients for $W$:enter image description here



      With this equation (where $q$ = [[0.22],[0.26]], I would think that for $W_1,2$ (which has a value of 0.5, and $i$ = 1 and $j$ = 2) would be equal to $2*q_1*x_2$, which in this case is $2*0.22*0.4 = 0.176$, which is not what they got.



      Intuitively, I thought the values of $W$ would be exactly what they calculated, but with $0.104$ and $0.176$ swapped. The way I calculated it was taking the top value of $q$ as the gradient on $0.22$ (which it is), and therefor, as $0.22 = 0.1*0.2 + 0.5*0.4$, taking $fracpartial qpartial W_1,1=0.2$, and then multiplying this by $q_1$, I got $0.2*0.44=0.088$, which aligns with their calculations.



      However, applying the same logic to $W_1,2$, I get $fracpartial qpartial W_1,2=0.4$, and multiplying this by $q_1$, $0.4*0.44=0.176$. This conflicts with their value of $0.104$. If this logic is continued, the matrix of gradients matches theirs exactly, aside from the $0.104$ and $0.176$ being swapped.



      For clarity, I also drew out a graph and deconstructed the matrix multiplication into simplified multiplication of two different regular equations. See below for the graph (where the numbers above nodes/inputs represent their gradient):





      (Sorry for bad hand writing and quality, there's a reason I submit all work using latex)



      I suspect I am using incorrect notation for $W$, as in, $W_1,2$ doesn't actually represent $0.5$, but actually $-0.3$, but then that doesn't align with their provided example of how the matrix $[[0.22],[0.26]]$ was constructed (the equation describing $q= W cdot x = ...$), and also doesn't explain how I got the values for the graph I hand drew, as that doesn't rely on notation.



      If you read all this and have any idea what I'm doing wrong I would very much appreciate your effort. Thankyou!










      share|improve this question







      New contributor




      Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I was watching a public available video from Stanford (https://youtu.be/d14TUNcbn1k?t=2720) on the mathematics behind back propagation. They proposed a graph:



      Graph 1



      that was then used as an example of back propagation using matrices. (The red text is the back propagated gradient, the green is the forward pass vales). The final gradients found for the initial matrices (of $[[0.1,0.5],[-0.3,0.8]]$ and $[[0.2],[0.4]]$) is below:
      enter image description here



      I agree with the values for $x$, however, I don't quite understand how they achieved the values of $W$. The equation (see circled in red) is the equation they used for calculating the gradients for $W$:enter image description here



      With this equation (where $q$ = [[0.22],[0.26]], I would think that for $W_1,2$ (which has a value of 0.5, and $i$ = 1 and $j$ = 2) would be equal to $2*q_1*x_2$, which in this case is $2*0.22*0.4 = 0.176$, which is not what they got.



      Intuitively, I thought the values of $W$ would be exactly what they calculated, but with $0.104$ and $0.176$ swapped. The way I calculated it was taking the top value of $q$ as the gradient on $0.22$ (which it is), and therefor, as $0.22 = 0.1*0.2 + 0.5*0.4$, taking $fracpartial qpartial W_1,1=0.2$, and then multiplying this by $q_1$, I got $0.2*0.44=0.088$, which aligns with their calculations.



      However, applying the same logic to $W_1,2$, I get $fracpartial qpartial W_1,2=0.4$, and multiplying this by $q_1$, $0.4*0.44=0.176$. This conflicts with their value of $0.104$. If this logic is continued, the matrix of gradients matches theirs exactly, aside from the $0.104$ and $0.176$ being swapped.



      For clarity, I also drew out a graph and deconstructed the matrix multiplication into simplified multiplication of two different regular equations. See below for the graph (where the numbers above nodes/inputs represent their gradient):





      (Sorry for bad hand writing and quality, there's a reason I submit all work using latex)



      I suspect I am using incorrect notation for $W$, as in, $W_1,2$ doesn't actually represent $0.5$, but actually $-0.3$, but then that doesn't align with their provided example of how the matrix $[[0.22],[0.26]]$ was constructed (the equation describing $q= W cdot x = ...$), and also doesn't explain how I got the values for the graph I hand drew, as that doesn't rely on notation.



      If you read all this and have any idea what I'm doing wrong I would very much appreciate your effort. Thankyou!







      backpropagation matrix






      share|improve this question







      New contributor




      Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 28 mins ago









      RecessiveRecessive

      101




      101




      New contributor




      Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Recessive is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "557"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Recessive is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f49745%2fis-this-an-incorrect-way-of-back-propagating-error-with-matrices%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Recessive is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Recessive is a new contributor. Be nice, and check out our Code of Conduct.












          Recessive is a new contributor. Be nice, and check out our Code of Conduct.











          Recessive is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Data Science Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f49745%2fis-this-an-incorrect-way-of-back-propagating-error-with-matrices%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          ValueError: Error when checking input: expected conv2d_13_input to have shape (3, 150, 150) but got array with shape (150, 150, 3)2019 Community Moderator ElectionError when checking : expected dense_1_input to have shape (None, 5) but got array with shape (200, 1)Error 'Expected 2D array, got 1D array instead:'ValueError: Error when checking input: expected lstm_41_input to have 3 dimensions, but got array with shape (40000,100)ValueError: Error when checking target: expected dense_1 to have shape (7,) but got array with shape (1,)ValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (0,)Keras exception: ValueError: Error when checking input: expected conv2d_1_input to have shape (150, 150, 3) but got array with shape (256, 256, 3)Steps taking too long to completewhen checking input: expected dense_1_input to have shape (13328,) but got array with shape (317,)ValueError: Error when checking target: expected dense_3 to have shape (None, 1) but got array with shape (7715, 40000)Keras exception: Error when checking input: expected dense_input to have shape (2,) but got array with shape (1,)

          Ружовы пелікан Змест Знешні выгляд | Пашырэнне | Асаблівасці біялогіі | Літаратура | НавігацыяДагледжаная версіяправерана1 зменаДагледжаная версіяправерана1 змена/ 22697590 Сістэматыкана ВіківідахВыявына Вікісховішчы174693363011049382

          Illegal assignment from SObject to ContactFetching String, Id from Map - Illegal Assignment Id to Field / ObjectError: Compile Error: Illegal assignment from String to BooleanError: List has no rows for assignment to SObjectError on Test Class - System.QueryException: List has no rows for assignment to SObjectRemote action problemDML requires SObject or SObject list type error“Illegal assignment from List to List”Test Class Fail: Batch Class: System.QueryException: List has no rows for assignment to SObjectMapping to a user'List has no rows for assignment to SObject' Mystery