{"id":1540,"date":"2021-10-15T16:49:57","date_gmt":"2021-10-15T14:49:57","guid":{"rendered":"https:\/\/maxfest.dk\/port\/?p=1540"},"modified":"2021-10-15T16:49:57","modified_gmt":"2021-10-15T14:49:57","slug":"noter-i-anvendt-machine-learning-optimization-and-regularization-15-10-2021","status":"publish","type":"post","link":"https:\/\/maxfest.dk\/port\/skiftligt-materiale\/noter\/noter-i-anvendt-machine-learning-optimization-and-regularization-15-10-2021\/","title":{"rendered":"Noter i Anvendt Machine learning &#8211; Optimization and regularization &#8211; 15\/10 2021"},"content":{"rendered":"\n<p>Memorising = overfitting.<\/p>\n\n\n\n<p>Large neural networks are tendent to overfit. And that is to be avoided.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Trade off between model and data<\/h2>\n\n\n\n<p>Regularization: to change data in a way that aids in avoiding overfitting.<\/p>\n\n\n\n<p>flatten can be used on data that is flattend, but is not necesary.<\/p>\n\n\n\n<p>When overfitting, it is because it has the capcit to fit disturbance patterns in the data (which is random noice). It will make the model perform worse.<\/p>\n\n\n\n<p>The simplest way to avoid overfitting is to se a simple model. It can still happen, but there is less options to do so.<\/p>\n\n\n\n<p>Large models have the potential to perform better when not overfitted.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Validation data as tool to detect overfitting<\/h2>\n\n\n\n<p>Vanishing gradient leads to weights of zero and small results.<\/p>\n\n\n\n<p>Exploding gradient leads to infinite weights and large results.<\/p>\n\n\n\n<p>Early stopping is stopping the model when it&#8217;s posible to tell that the model started stagnate.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Weight regulariztion as tool to improve generalization<\/h2>\n\n\n\n<p>Weight is hard to regularize, as it can only be optimized through trial and error.<\/p>\n\n\n\n<p>Weight reularization can be done with weight. This is done by shinkage. Weights for poor classifiers are set to 0.<\/p>\n\n\n\n<p>Weight regulariation can be done with l1 and l2.<\/p>\n\n\n\n<p>Weight initialization can also be uses. Which is to adjust weights before training start.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dropout as tool to improve generalization<\/h2>\n\n\n\n<p>Dropout can be used to reguralize by removing some connections at a given layer. It introduces noice and limits the potential of hidden nodes to co-addapt.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-1024x558.png\" alt=\"\" class=\"wp-image-1546\" srcset=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-1024x558.png 1024w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-300x164.png 300w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-768x419.png 768w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout.png 1249w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>How dropout works &#8211; Source: &#8220;Srivastava, N., Hinton, G., Krizhevsky, A., Sutskever, I., &amp; Salakhutdinov, R. (2014). Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research, 15(1), 1929-1958.&#8221;<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"306\" src=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-train-test-difference-1024x306.png\" alt=\"\" class=\"wp-image-1547\" srcset=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-train-test-difference-1024x306.png 1024w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-train-test-difference-300x90.png 300w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-train-test-difference-768x230.png 768w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/dropout-train-test-difference.png 1469w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Dropout at training and test &#8211; Source: &#8220;Srivastava, N., Hinton, G., Krizhevsky, A., Sutskever, I., &amp; Salakhutdinov, R. (2014). Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research, 15(1), 1929-1958.&#8221;<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Batch normalization as tool to improve training and generalization<\/h2>\n\n\n\n<p>Batch normalization is good to implement before dropout. This will be discoused later.<\/p>\n\n\n\n<p>Normalizing can help not only at the input layer, but at every layer. Batch normalizion is an option to do that.<\/p>\n\n\n\n<p>It does have some drawbacks. It reqires a slow learning rate, carefull initialization and it may saturate non-linearties by making gradients.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"448\" src=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/bn-algorithm.png\" alt=\"\" class=\"wp-image-1548\" srcset=\"https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/bn-algorithm.png 623w, https:\/\/maxfest.dk\/port\/wp-content\/uploads\/2021\/10\/bn-algorithm-300x216.png 300w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><figcaption>Batch normalization algorithm &#8211; Source: &#8220;Ioffe, S., &amp; Szegedy, C. (2015). Batch normalization: Accelerating deep network training by reducing internal covariate shift. arXiv preprint arXiv:1502.03167.&#8221;<\/figcaption><\/figure>\n\n\n\n<p>\u03b3\u00a0and\u00a0<em>B<\/em> (the betta) introduces bias, but since they are trainable, they can be optimized. Ecentialy noice is introduced only to be further reduced.<\/p>\n\n\n\n<p>Batch normalization is allmost allways a good idea.<\/p>\n\n\n\n<p>Small batch sizes don&#8217;t allways work so well &#8211; especially batch sizes of 1. To large batch sizes might introduce other problems too.<\/p>\n\n\n\n<p>It does require somewhat high computeational power.<\/p>\n\n\n\n<p>Batch normilization works well with other methods of normilization. Usually dropout.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Data augmentation<\/h2>\n\n\n\n<p>With a set of data, eg. images, especially a small sample, the data can be transormed in some degree to be computated as new data.<\/p>\n\n\n\n<p>This could be done by rotating, asdjusting colors, fliping and introduce noice to the pictures.<\/p>\n\n\n\n<p>Augmentation will add a lot more data to the dataset.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Memorising = overfitting. Large neural networks are tendent to overfit. And that is to be avoided. Trade off between model and data Regularization: to change data in a way that aids in avoiding overfitting. flatten can be used on data that is flattend, but is not necesary. When overfitting, it is because it has 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],"tags":[34,30],"class_list":["post-1540","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-noter","tag-anvendt-maskinlaering-ds807","tag-sdu"],"_links":{"self":[{"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/posts\/1540","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=1540"}],"version-history":[{"count":10,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/posts\/1540\/revisions"}],"predecessor-version":[{"id":1553,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/posts\/1540\/revisions\/1553"}],"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=1540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/categories?post=1540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/maxfest.dk\/port\/wp-json\/wp\/v2\/tags?post=1540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}