{"id":8710,"date":"2026-08-16T17:59:37","date_gmt":"2026-08-16T16:59:37","guid":{"rendered":"https:\/\/sinatootoonian.com\/?p=8710"},"modified":"2026-08-16T17:59:38","modified_gmt":"2026-08-16T16:59:38","slug":"why-gradient-descent","status":"publish","type":"post","link":"https:\/\/sinatootoonian.com\/index.php\/2026\/08\/16\/why-gradient-descent\/","title":{"rendered":"Why Gradient Descent"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">When we think about learning the parameters of a neural network, we naturally think of gradient descent, because what else can we really do? It turns out that there is something else we can do, namely function evaluation, but that gradient descent, at least in a neural network setting, can be enormously more efficient.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I came across this while reading Section 5.2.1, &#8220;Parameter Optimization&#8221; in Bishop&#8217;s PRML in preparation for the <a href=\"https:\/\/www.youtube.com\/watch?v=bUwzBcHzSD0\">video<\/a> I posted on the section today.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The setting was minimizing a quadratic approximation to the loss function of a neural network: $$ E(\\ww) \\approx E(\\ww_0) + (\\ww &#8211; \\ww_0)^T \\bb + {1 \\over 2} (\\ww &#8211; \\ww_0)^T \\HH (\\ww &#8211; \\ww_0).$$ <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The parameter vector $\\ww$ represents all $W$ weights in the networks. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bishop&#8217;s first point was that we need $O(W^2)$ independent pieces of information to determine this function, and hence to find its minimum: $W$ in $\\bb$, and $W(W+1)\/2$ for $\\HH$. So far so good.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, one way we can get those pieces of information is function evaluation, evaluating the loss at a given point. Each such evaluation gives us one piece of information, so performing $O(W^2)$ evaluations gives us all the information we need to determine the loss function, and hence its minimum. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How much does gathering this information cost? Each function evaluation costs a feedforward pass through the network, so $O(W)$ operations. The total cost of this approach is then $O(W^2)$ evaluations $\\times O(W)$ operations per evaluation, yielding $O(W^3)$ total operations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What if we used gradients instead? Each evaluation of $\\nabla E(\\ww)$ gives us $W$ pieces of information: the gradient of the loss relative to each of the $W$ weights. So, we should need $O(W)$ such operations to get $O(W^2)$ pieces of information. How much does this cost? <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One might think that if one function evaluation cost $O(W)$, then, since the gradient is $W$ such functions, it would cost $O(W^2)$ to compute the gradient. But, it turns out that it we use backpropagation, the gradient evaluation also costs $O(W)$ operations, the same as a single function evaluation! We&#8217;re therefore getting $W$-times more information, or the same information at $1\/W$ the cost! <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The total cost of getting $O(W^2)$ pieces of information then becomes $O(W) $ evaluations $\\times O(W) $ operations per evaluation, yielding $O(W^2)$ total operations, a factor of $W$ less than function evaluation! And in the modern setting where deep nets can have billions of parameters, a factor of $W$ difference is enormous!<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Method<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Info \/ Eval<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong># Evals<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Cost \/ Eval <\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Total Cost<\/strong><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">Function Evaluation<\/td><td class=\"has-text-align-center\" data-align=\"center\">1<\/td><td class=\"has-text-align-center\" data-align=\"center\">$W^2$<\/td><td class=\"has-text-align-center\" data-align=\"center\">$W$<\/td><td class=\"has-text-align-center\" data-align=\"center\">$W^3$<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">Gradient Evaluation<\/td><td class=\"has-text-align-center\" data-align=\"center\">$W$<\/td><td class=\"has-text-align-center\" data-align=\"center\">$W$<\/td><td class=\"has-text-align-center\" data-align=\"center\">$W$<\/td><td class=\"has-text-align-center\" data-align=\"center\">$W^2$<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;m now excited to find out how backpropagation can be so efficient&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$$\\blacksquare$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When we think about learning the parameters of a neural network, we naturally think of gradient descent, because what else can we really do? It turns out that there is something else we can do, namely function evaluation, but that gradient descent, at least in a neural network setting, can be enormously more efficient. I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[150,1],"tags":[],"class_list":["post-8710","post","type-post","status-publish","format-standard","hentry","category-bishop","category-blog"],"acf":[],"_links":{"self":[{"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/posts\/8710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/comments?post=8710"}],"version-history":[{"count":10,"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/posts\/8710\/revisions"}],"predecessor-version":[{"id":8720,"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/posts\/8710\/revisions\/8720"}],"wp:attachment":[{"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/media?parent=8710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/categories?post=8710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sinatootoonian.com\/index.php\/wp-json\/wp\/v2\/tags?post=8710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}