{"id":199,"date":"2018-01-08T00:15:00","date_gmt":"2018-01-08T00:15:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/2018\/01\/08\/basics-of-backpropagation-in-neural-networksmachine-learning\/"},"modified":"2018-01-08T00:15:00","modified_gmt":"2018-01-08T00:15:00","slug":"basics-of-backpropagation-in-neural-networksmachine-learning","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/basics-of-backpropagation-in-neural-networksmachine-learning\/","title":{"rendered":"Basics of Backpropagation in Neural Networks(Machine Learning)"},"content":{"rendered":"<div style=\"color: #555555; font-size: 18px; line-height: 30px; text-align: justify;\">\n<div style=\"font-family: 'segoe ui';\"><span style=\"color: #0b5394;\"><b>Backpropagation <\/b><\/span>is the learning algorithm used in neural networks and is a generalization of the least mean squares algorithm used in linear perceptron. Backpropagation requires a known and expected output value for each input value and therefore it is therefore a supervised learning method.<\/p>\n<p><b>How It Works<\/b><br \/>Remember backpropagation is a learning algorithm. How does learning occur? Learning is done by changing the weights of the perceptron after each signal have been processed based on the calculated amount of error in the output compared to the expected result.<\/p>\n<div style=\"text-align: center;\"><b><span style=\"color: #cc0000;\"><span style=\"font-family: &quot;georgia&quot; , &quot;times new roman&quot; , serif;\"><i>Error = Output perceptron &#8211; expected result<\/i><\/span><\/span><\/b><\/div>\n<p><b>Calculating the Loss Function<\/b><br \/>To understand the backpropagation algorithm, you need to understand the concept of the Loss Function which is also the Cost function. This is loosely the same as the error formula above, but this time we would need to formalize the definition a little. It would still be easy and clear.<\/div>\n<div style=\"font-family: 'segoe ui';\">The loss function calculates the difference between the output of the network and the expected output.<\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"font-family: 'segoe ui';\">Let y, y&#8217; be vectors in <span style=\"background-color: white; color: #222222; display: inline; float: none; font-family: sans-serif; font-size: 14px; font-style: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;\">\u211d<sup>n<\/sup><\/span><\/div>\n<div style=\"font-family: 'segoe ui';\">We select an error function E(y, y&#8217;) which give the difference between outputs y and y&#8217; which is given by:<\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/2.bp.blogspot.com\/-5AJB6Xybw3Q\/WlKvaw16sYI\/AAAAAAAAApU\/Nfv4Z6G57e834VB2Z7_Orliu4-cZdnuRACLcBGAs\/s1600\/Standard-error-choice.jpg\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" data-original-height=\"77\" data-original-width=\"375\" height=\"65\" src=\"https:\/\/2.bp.blogspot.com\/-5AJB6Xybw3Q\/WlKvaw16sYI\/AAAAAAAAApU\/Nfv4Z6G57e834VB2Z7_Orliu4-cZdnuRACLcBGAs\/s320\/Standard-error-choice.jpg\" width=\"320\" \/><\/a><\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"font-family: 'segoe ui';\">The error function would be given by the square of the Euclidean distance between y and y&#8217; as shown below:<\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"font-family: 'segoe ui';\">For n training examples, the average error can would be given by:<\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/4.bp.blogspot.com\/-Rav-vEkCOcg\/WlKt1OlMptI\/AAAAAAAAApI\/IKhWfovOvBw_SJPXWrroFjRf_rfTI4dOACLcBGAs\/s1600\/Error-Function-over-n-data-sets.jpg\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" data-original-height=\"132\" data-original-width=\"490\" height=\"84\" src=\"https:\/\/4.bp.blogspot.com\/-Rav-vEkCOcg\/WlKt1OlMptI\/AAAAAAAAApI\/IKhWfovOvBw_SJPXWrroFjRf_rfTI4dOACLcBGAs\/s320\/Error-Function-over-n-data-sets.jpg\" width=\"320\" \/><\/a><\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"font-family: 'segoe ui';\">The partial derivatives with respects to y and y&#8217; would be given by:<\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/2.bp.blogspot.com\/-c420WzVhEys\/WlKxDlM5YEI\/AAAAAAAAApg\/v_w6LmDz8FUQMCnFFrmhgoCWBOl8C30sgCLcBGAs\/s1600\/Derivatives%2Bof%2BError.jpg\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" data-original-height=\"110\" data-original-width=\"605\" height=\"58\" src=\"https:\/\/2.bp.blogspot.com\/-c420WzVhEys\/WlKxDlM5YEI\/AAAAAAAAApg\/v_w6LmDz8FUQMCnFFrmhgoCWBOl8C30sgCLcBGAs\/s320\/Derivatives%2Bof%2BError.jpg\" width=\"320\" \/><\/a><\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"font-family: 'segoe ui';\">You have come a long way in understanding the backpropagation algorithm. Just take some time to get these formulas around your head because that is what would form the basis of understanding the backpagation algorithm<\/div>\n<div style=\"font-family: 'segoe ui';\"><\/div>\n<div style=\"font-family: 'segoe ui';\"><b>The Backpropagation Algorithm<\/b><\/div>\n<div style=\"font-family: 'segoe ui';\">The algorithm starts when an input vector <b>x<\/b> is entered into the network. This input moves from the input layer through the hidden layers to the output layer and produces an output y.&nbsp;<\/div>\n<div style=\"font-family: 'segoe ui';\">The loss function is used to compare this output with the expected(or actual) output to give an error value. The error value is calculated for each of the neurons in the output layer.&nbsp;<\/div>\n<div style=\"font-family: 'segoe ui';\">These error values are then propagated backwards from the output layer, through the network.<\/div>\n<p><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><br \/><\/span><span style=\"font-family: &quot;verdana&quot; , sans-serif;\">Backpropagation uses these error values to calculate the gradient of the loss function as they are move back through the network. This gradient, is then used to update the weights of the nodes. The process is repeated again to get another output based on the updated weights. The process of backpropagation is repeated until the error function produces a minimum value.<\/span><br \/><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><br \/><\/span><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><b>Summary of the Backpropagation Algorithm<\/b><\/span><\/p>\n<ol><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><\/span><\/p>\n<li><span style=\"font-family: &quot;verdana&quot; , sans-serif;\">Input vector <b>x<\/b> is given to the network&nbsp;<\/span><\/li>\n<p><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><\/span><\/p>\n<li><span style=\"font-family: &quot;verdana&quot; , sans-serif;\">Input propagates forward to produce an output y in the output layer&nbsp;<\/span><\/li>\n<p><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><\/span><\/p>\n<li><span style=\"font-family: &quot;verdana&quot; , sans-serif;\">Error function is calculated&nbsp;<\/span><\/li>\n<p><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><\/span><\/p>\n<li><span style=\"font-family: &quot;verdana&quot; , sans-serif;\">Error is propagated backwards into the network&nbsp;<\/span><\/li>\n<p><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><\/span><\/p>\n<li><span style=\"font-family: &quot;verdana&quot; , sans-serif;\">Weights are adjusted accordingly&nbsp;<\/span><\/li>\n<p><span style=\"font-family: &quot;verdana&quot; , sans-serif;\"><\/span><\/p>\n<li><span style=\"font-family: &quot;verdana&quot; , sans-serif;\">Repeat the process until the final error is minimum  <\/span><\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Backpropagation is the learning algorithm used in neural networks and is a generalization of the least mean squares algorithm used in linear perceptron. Backpropagation requires &hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[16,14],"tags":[],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/199"}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=199"}],"version-history":[{"count":0,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/199\/revisions"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}