 {"id":195,"date":"2019-08-28T22:30:55","date_gmt":"2019-08-29T05:30:55","guid":{"rendered":"https:\/\/joshuarenglish.com\/blog\/?p=195"},"modified":"2019-08-28T22:30:58","modified_gmt":"2019-08-29T05:30:58","slug":"uncle-josh-scrapes-his-knuckles-on-ml-pt-4","status":"publish","type":"post","link":"https:\/\/joshuarenglish.com\/blog\/2019\/08\/28\/uncle-josh-scrapes-his-knuckles-on-ml-pt-4\/","title":{"rendered":"Uncle Josh Scrapes His Knuckles on ML, Pt. 4"},"content":{"rendered":"\n<p>I did some simple work with JSON getting the thinker saved and I should be able to reconstitute them at will. I will confirm this is working when I have something worth saving. I have a Python object that can read the five inputs from the map, run them through the matrices, and spit out an angle that it needs to turn. I even added little tracing circles to show the path of the thing as it &#8220;navigates&#8221; the maze:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"741\" src=\"https:\/\/joshuarenglish.com\/blog\/wp-content\/uploads\/2019\/08\/CircularThinking.png\" alt=\"Screenshot of a runner going in a circle\" class=\"wp-image-191\" srcset=\"https:\/\/joshuarenglish.com\/blog\/wp-content\/uploads\/2019\/08\/CircularThinking.png 732w, https:\/\/joshuarenglish.com\/blog\/wp-content\/uploads\/2019\/08\/CircularThinking-296x300.png 296w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><figcaption>Circular Thinking Is NOT Running a Maze<\/figcaption><\/figure>\n\n\n\n<p>Most of the time the Thinker spits out a 1, but some times it spits out different numbers but they aren&#8217;t different enough to make much of a difference. A few tests had the runner spiraling very slowly, but still running essentially in circles. For all of these tests I&#8217;m having the thinker object randomize its synapses and biases.<\/p>\n\n\n\n<p>Obviously, these random numbers aren&#8217;t enough to make the damn thing  do anything interesting.<\/p>\n\n\n\n<p>The first map I have is 400 pixels by 400 pixels, so the distances could be anything from 0 to 400. I need to examine the weights of these randomized thinkers to see if I can find a pattern. While messing with the outputs to  format them nicely (I don&#8217;t think I need 20 decimal places to analyze the data), I came across this guy:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"741\" src=\"https:\/\/joshuarenglish.com\/blog\/wp-content\/uploads\/2019\/08\/MeanderingThinking.png\" alt=\"Runner moving in a wider spiral but still not doing very well.\" class=\"wp-image-196\" srcset=\"https:\/\/joshuarenglish.com\/blog\/wp-content\/uploads\/2019\/08\/MeanderingThinking.png 732w, https:\/\/joshuarenglish.com\/blog\/wp-content\/uploads\/2019\/08\/MeanderingThinking-296x300.png 296w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><figcaption>Modal Meandering?<\/figcaption><\/figure>\n\n\n\n<p>Scanning the outputs, this guy had two results: either somewhere around 0.13 (rarely 0.122) or around 0.29. The end result is squished between 0 and 1, remember, and then I multiply by 2, subtract 1, and multiply by tau\/40. Here&#8217;s the JSON output of the randomized thinker:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\"input_count\": 5, \n \"layers\": [3, 4], \n \"output_count\": 1, \n \"synapses\": [\n    [[-0.4914, -0.4220, 0.8770, 0.7782,  0.0148], \n     [ 0.3659, -0.8196, 0.0923, 0.3097, -0.1648], \n     [-0.8482,  0.1504, 0.8237, 0.1866,  0.8727]], \n    [[-0.8820,  0.8718, 0.2187],  \n     [-0.5129, -0.3895, -0.8474],    \n     [-0.7380, -0.5483,  0.5057], \n     [ 0.2030, -0.8571, -0.8560]], \n    [[0.7712, 0.5206, -0.8747, 0.9804]]], \n \"weights\": [\n    [[-115.6903], [-171.2310], [-42.1870]], \n    [[-0.3743], [0.2523], [-0.1249], [-0.5520]], \n    [[0.0490]]], \n \"weight_range\": [-200, 0], \n \"synapse_range\": [-1, 1], \n \"<strong>jsoncls<\/strong>\": \"Thinker\"}<\/pre>\n\n\n\n<p>The weight_range only takes effect in the first level. My logic was after the inputs are weighted into the first hidden layer, then the values are squished to between 0 and 1, so massive weights may not be useful, I thought. I have yet to find a resource that explains how to come up with sensible values here.<\/p>\n\n\n\n<p>I also printed out the first steps of the calculations, which may also explain what&#8217;s going on here.<\/p>\n\n\n\n<p>After doing the matrix multiplication of the first synapses and the inputs, adding the weights, and squishing;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[[2.17313e-62]\n [2.82042e-71]\n [1.00000e+00]]<\/pre>\n\n\n\n<p>So the first hidden layer results in basically 0, 0, 1.  This seems to flatten the whole thing.<\/p>\n\n\n\n<p>The inputs (distances) and final output for the first two steps are:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">['200.00', '70.71', '50.00', '70.71', '200.00'] 0.1306522164636137\n['200.77', '254.29', '45.34', '57.42', '201.94'] 0.13065221646348157<\/pre>\n\n\n\n<p>The distances are different, but the results are the same. Reviewing the rest of the intermittent calculations, the first round of <span class=\"katex-eq\" data-katex-display=\"false\">\\sigma(m \\cdot i + w)<\/span> always returns [0, 0, 1] or something so close the math never recovers. I have some numbers with e-106 in this list. When the first round ends in [0, 0, 0] I get a different result (close to 0.29).<\/p>\n\n\n\n<p>That&#8217;s the source of the problem, I think. Now I can play around with the weight_range options and see if I get some real variation in actions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I did some simple work with JSON getting the thinker saved and I should be able to reconstitute them at will. I will confirm this is working when I have something worth saving. I have a Python object that can read the five inputs from the map, run them through the matrices, and spit out &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","_share_on_mastodon":"0"},"categories":[34],"tags":[91,92],"class_list":["post-195","post","type-post","status-publish","format-standard","hentry","category-boxes-that-go-bing","tag-machine-learning","tag-python"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":4,"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"predecessor-version":[{"id":200,"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/posts\/195\/revisions\/200"}],"wp:attachment":[{"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joshuarenglish.com\/blog\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}