{"id":1489,"date":"2021-10-11T17:58:26","date_gmt":"2021-10-11T15:58:26","guid":{"rendered":"https:\/\/maxfest.dk\/port\/?p=1489"},"modified":"2021-10-13T09:28:06","modified_gmt":"2021-10-13T07:28:06","slug":"deep-learning-noter-gradient-based-learning-11-10-2021","status":"publish","type":"post","link":"https:\/\/maxfest.dk\/port\/vearker\/deep-learning-noter-gradient-based-learning-11-10-2021\/","title":{"rendered":"Deep learning noter  &#8211; Gradient based learning &#8211; 11 &#038; 13\/10 2021"},"content":{"rendered":"\r\n<p>With a liminiear approximation can be made from the gradiant. This is done by going the oposite direction.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"771\" class=\"wp-image-1497\" src=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-8-1024x771.png\" alt=\"\" srcset=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-8-1024x771.png 1024w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-8-300x226.png 300w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-8-768x578.png 768w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-8.png 1078w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/>\r\n<figcaption>Usage of Derivates &#8211; Source: SDU<\/figcaption>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>With multiple inputs it is used the same way, but returns an output with weights matching the amount of dimensions of the input.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">SGD<\/h2>\r\n\r\n\r\n\r\n<p>SGD is using mini batches. Instead of using all connections to get the most precesise results, batches are used to approximate the result somewhat wore propbably.<\/p>\r\n\r\n\r\n\r\n<p>From the mini batches an average gradient is calculated and used.<\/p>\r\n\r\n\r\n\r\n<p>The positive asspect of SGD is that it is faster.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Deep learning specialities<\/h2>\r\n\r\n\r\n\r\n<p>Deep learning needs the same components as machine learning<\/p>\r\n\r\n\r\n\r\n<ol class=\"wp-block-list\">\r\n<li>Optimization procedure<\/li>\r\n<li>Cost function<\/li>\r\n<li>Model family<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<p>Differences causes non-convex loss.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\">Problems<\/h3>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Can end in local minimum<\/li>\r\n<li>Can end in local maximum<\/li>\r\n<li>Can end at saddle points &#8211; The worst point: learning is stopped, and the results are likely not good.<\/li>\r\n<li>Learning rate &#8211; Big learning rates might have large jumps in results and small learning rates might be slow.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>If a particular bad promlem or cliff is encountered, new initialization might be the best solution.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\">Cliffs and exploding gradients<\/h3>\r\n\r\n\r\n\r\n<p>Cliffs in Neural Network are sudden drops or rices in learning.<\/p>\r\n\r\n\r\n\r\n<p>Theese can be midigated by implementing a gradient.<\/p>\r\n\r\n\r\n\r\n<p>Inexact gradients are caused by biace or variance.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">About gradients<\/h2>\r\n\r\n\r\n\r\n<p>Gradients must be large and somewhat predictable to guide the learning algorithm.<\/p>\r\n\r\n\r\n\r\n<p>Functions that saturate (flatten results) undermine gradients.<\/p>\r\n\r\n\r\n\r\n<p>Negative log-likelihood helps avoid saturation problem for many models. It undoees gradient accidents as far as i understand.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Different optimizers<\/h2>\r\n\r\n\r\n\r\n<p><\/p>\r\n<ul class=\"wp-block-list\">\r\n<li>SGD\r\n<ul>\r\n<li>Standard gradient decent<\/li>\r\n<li>utilizes decay, momentum, and Nesterov<\/li>\r\n<\/ul>\r\n<ul>\r\n<li>for frequent parameter<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>RMSProp\r\n<ul>\r\n<li>Root Mean Square Propagation<\/li>\r\n<li>utilizes exponentially decaying running average of the squared gradients (similar to momentum)<\/li>\r\n<li>decay is usually 0.9.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>Adagrad\r\n<ul>\r\n<li>utilizes larger updates for infrequent parameters and smaller updates<\/li>\r\n<li>Good for word embeddings with that has infrequent words<\/li>\r\n<li>Often has diminising learning rate<\/li>\r\n<li>Tries to ease on the diminishing learning rate decay from Adagrad<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>Adadelta\r\n<ul>\r\n<li>similar to RMSProp<\/li>\r\n<li>utilizes root squared parameter updates<\/li>\r\n<li>Does not need set learning rate<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>Adam\r\n<ul>\r\n<li>Adaptive Moment Estimation<\/li>\r\n<li>prefers flat minima in the error surface<\/li>\r\n<li>Adam is basically RMSProp with momentum<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>Adamax\r\n<ul>\r\n<li>Same as Adam, but based on the max-norm ^inf.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>Nadam\r\n<ul>\r\n<li>Nesterov-accelerated Adaptive Moment Estimation<\/li>\r\n<li>Nadam is basically Adam with Nesterov momentum<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<p>\r\n\r\n<\/p>\r\n<p>Choosing a bad optimizer or bad parameters in general, can lead to inefeicent or slow learning.<\/p>\r\n<p>\r\n\r\n<\/p>\r\n<p>Batch gradient decent can use fixed learning rate.<\/p>\r\n<p>\r\n\r\n<\/p>\r\n<p>SGD jas a source error.<\/p>\r\n<p>\r\n\r\n<\/p>\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"212\" height=\"57\" class=\"wp-image-1507\" src=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-9.png\" alt=\"\" \/>\r\n<figcaption>Source: SDU<\/figcaption>\r\n<\/figure>\r\n<p>\r\n\r\n<\/p>\r\n<h3 class=\"wp-block-heading\">Momentum<\/h3>\r\n<p>\r\n\r\n<\/p>\r\n<p>Momentum hels accelerea gradientdecent. Usefull when<\/p>\r\n<p>\r\n\r\n<\/p>\r\n<ul class=\"wp-block-list\">\r\n<li>Surfaces that curve more steeply in one direction than in another direction<br \/>\u00a7 Facing high curvature<br \/>\u00a7 Small but consistent gradients<br \/>\u00a7 Noisy gradients<\/li>\r\n<\/ul>\r\n<p>\r\n\r\n<\/p>\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"300\" class=\"wp-image-1508\" src=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-10.png\" alt=\"\" srcset=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-10.png 716w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-10-300x126.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/>\r\n<figcaption>Dampening of the oscillation &#8211; Source: SDU<\/figcaption>\r\n<\/figure>\r\n<p>\r\n\r\n<\/p>\r\n<p>Note: The need for dampening of the oscilation can only be found trhough trial and error.<\/p>\r\n<p>\r\n\r\n<\/p>\r\n<p>Momentum introduces velocity, v. It is the direction and speed at which parameters move through parameter<br \/>space. Also known as mass in physics.<\/p>\r\n<p>\r\n\r\n<\/p>\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"132\" class=\"wp-image-1509\" src=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-11.png\" alt=\"\" srcset=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-11.png 400w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-11-300x99.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/>\r\n<figcaption>Source: SDU<\/figcaption>\r\n<\/figure>\r\n<p>\r\n\r\n<\/p>\r\n<h3 class=\"wp-block-heading\">Nesterov Accelerated Gradient<\/h3>\r\n<p>\r\n\r\n<\/p>\r\n<p>Calculation of gradient if implementet.<\/p>\r\n<p>\r\n\r\n<\/p>\r\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1510\" src=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-12.png\" alt=\"\" width=\"800\" height=\"254\" srcset=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-12.png 800w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-12-300x95.png 300w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/image-12-768x244.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/>\r\n<figcaption>Nesterov Accelerated Gradient &#8211; Source: SDU<\/figcaption>\r\n<\/figure>\r\n<p>\r\n\r\n<\/p>\r\n<h3 class=\"wp-block-heading\">Adaptive Learning Rate (ada)<\/h3>\r\n<p>\r\n\r\n<\/p>\r\n<p>Learning rate for each adaptive parameter.<\/p>\r\n<p><\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>With a liminiear approximation can be made from the gradiant. This is done by going the oposite direction. With multiple inputs it is used the same way, but returns an output with weights matching the amount of dimensions of the input. SGD SGD is using mini batches. Instead of using all connections to get the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":715,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,1],"tags":[33,30],"class_list":["post-1489","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-noter","category-vearker","tag-deep-learning","tag-sdu"],"_links":{"self":[{"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/posts\/1489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/comments?post=1489"}],"version-history":[{"count":7,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/posts\/1489\/revisions"}],"predecessor-version":[{"id":1521,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/posts\/1489\/revisions\/1521"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/media\/715"}],"wp:attachment":[{"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/media?parent=1489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/categories?post=1489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/tags?post=1489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}