{"id":358525,"date":"2024-05-21T00:13:40","date_gmt":"2024-05-21T00:13:40","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=358525"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T00:13:40","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=358525","title":{"rendered":"<span>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0418\u0418 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c. TensorFlow + Node Js<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432 \u043e\u0431\u043e \u043c\u043d\u0435: \u043c\u043e\u0435 \u0445\u043e\u0431\u0431\u0438 \u044d\u0442\u043e \u0440\u043e\u0431\u043e\u0442\u043e\u0442\u0435\u0445\u043d\u0438\u043a\u0430. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u0441 \u0448\u0430\u0433\u0430\u044e\u0449\u0438\u043c \u0440\u043e\u0431\u043e\u0442\u043e\u043c \u043d\u0430 \u0431\u0430\u0437\u0435 SunFounder PiCrawler. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u043c\u0430 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430 (\u0418\u0418) \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u0443\u0436\u0438\u0442 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u0432 &#8212; \u043e\u043d\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043c\u043e\u0449\u043d\u0435\u0435 \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u0435\u0435.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0418\u0418 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 TensorFlow.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9dc\/3cc\/3bc\/9dc3cc3bcbea18b89b2e5a4f1361b4f4.png\" alt=\"PiCrawler\" title=\"PiCrawler\" width=\"589\" height=\"525\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9dc\/3cc\/3bc\/9dc3cc3bcbea18b89b2e5a4f1361b4f4.png\"\/><\/p>\n<div><figcaption>PiCrawler<\/figcaption><\/div>\n<\/figure>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0418\u0418 ?<\/h2>\n<p>\u041a\u0440\u0430\u0442\u043a\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 &#8212; \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0418\u0418 \u043c\u044b \u0440\u0435\u0448\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0438 \u043a\u0430\u043a\u0438\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435. \u041f\u043e\u0442\u043e\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0431\u0443\u0434\u044c \u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435 \u0438 &#171;\u0442\u0440\u0435\u043d\u0438\u0440\u0443\u0435\u043c&#187; \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0440\u043e\u0431\u043e\u0442\u0435 PiCrawler<\/h2>\n<p>\u042d\u0442\u043e \u0434\u0435\u0432\u0430\u0439\u0441, \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 AliExpress. \u0414\u043b\u044f \u0435\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 Raspberry Pi 4. \u0420\u043e\u0431\u043e\u0442 \u0438\u043c\u0435\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u043d\u043e\u0433\u0438, \u043f\u043b\u0430\u0442\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0443\u044e \u043f\u043e i2c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443, \u043a\u0430\u043c\u0435\u0440\u0443, \u0443\u043b\u044c\u0442\u0440\u0430\u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u0434\u0430\u0442\u0447\u0438\u043a \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u044b\u0445\u043e\u0434\u044b. <\/p>\n<p>\u042f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u043a \u044d\u0442\u043e\u043c\u0443 \u0440\u043e\u0431\u043e\u0442\u0443 \u043c\u0438\u043d\u0438-\u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f WT901 (\u043c\u043e\u0436\u043d\u043e \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439), \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u043e\u043c \u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u0435 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439 \u043f\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 i2c. \u0418\u043c\u0435\u0435\u0442\u0441\u044f \u041f\u041e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0433\u0430\u043c\u0438.<\/p>\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u0432\u043e\u0437\u044c\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c &#8212; \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u0433\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u043e\u043f\u043e\u0440\u043d\u043e\u0439 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u043e\u0431\u043e\u0442\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f, \u0441 \u043d\u0435\u0433\u043e \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 <code>x, y<\/code> \u0438 \u0443\u0436\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u043e\u0433 <code>y1, y2, y3, y4<\/code>, <\/p>\n<p>\u0433\u0434\u0435 <code>x, y, y1, y2, y3, y4<\/code> &#8212; \u0447\u0438\u0441\u043b\u0430.<\/p>\n<p>API \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Tensor-\u044b &#8212; \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f. <\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 <code>[x, y]<\/code>, \u0430 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 <code>[y1, y2, y3, y4]<\/code><\/p>\n<p>\u0412 \u0432\u0438\u0434\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u044d\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e0e\/f06\/26f\/e0ef0626f0bf9946c556c346228a8aa4.png\" width=\"446\" height=\"362\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e0e\/f06\/26f\/e0ef0626f0bf9946c556c346228a8aa4.png\"\/><\/figure>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438 TensorFlow<\/h2>\n<p>\u0418 \u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>[x, y]<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>[y1, y2, y3, y4]<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0436\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e layers-\u043c\u043e\u0434\u0435\u043b\u044c \u0432 Tensorflow &#8212; \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 &#8212; \u044d\u0442\u043e <code>inputShape: [2]<\/code>, \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 &#8212; <code>units: 4<\/code> \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">const tf = require(\"@tensorflow\/tfjs-node\"); const model = tf.sequential();  model.add(tf.layers.dense({ inputShape: [2], units: 32, activation: \"relu\" })); model.add(tf.layers.dense({ units: 32, activation: \"relu6\" })); model.add(tf.layers.dense({ units: 32, activation: \"relu6\" })); model.add(tf.layers.dense({ units: 4, activation: \"relu\" }));  model.summary(); model.compile({   optimizer: tf.train.sgd(0.0001),   loss: \"meanSquaredError\", });<\/code><\/pre>\n<p>\u0418 \u0442\u0430\u043a, \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0433\u043e\u0442\u043e\u0432\u0430! \u041d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438?<\/p>\n<h2>\u0421\u0431\u043e\u0440 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/h2>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435? \u042d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0438\u0445 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439. \u0417\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. <\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c? \u042d\u0442\u043e \u0432\u0441\u0435 \u0442\u0435 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438 &#8212; \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0423 \u0434\u043b\u044f \u043d\u043e\u0433 \u0440\u043e\u0431\u043e\u0442\u0430. \u041d\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 \u0440\u043e\u0431\u043e\u0442\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 &#8212; \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0435\u043c \u0440\u043e\u0431\u043e\u0442, \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u043e\u0433 \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430. \u0422\u0443\u0442 \u0432\u0430\u0436\u043d\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0438 \u0432 \u043a\u0430\u043a\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0435\u0433\u043e \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0442\u044c.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b: <\/p>\n<ul>\n<li>\n<p> <code>gyroScope<\/code> &#8212; \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430. \u041f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>getData()<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>{ X, Y }<\/code> \u0441 \u0443\u0433\u043b\u0430\u043c\u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u0430. <\/p>\n<\/li>\n<li>\n<p><code>leftArm, rightArm, leftArmBack, rightArmBack<\/code> &#8212; \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>setCoords<\/code> \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043d\u043e\u0433 \u0440\u043e\u0431\u043e\u0442\u0430. \u0414\u043b\u044f \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043f\u043e \u043e\u0441\u0438 Y<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0417\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435!<\/strong> <\/p>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e &#8212; \u044d\u0442\u043e \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>Y &#8212; \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 [-80, -80, -80, -80] &#8212; \u0414\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [0, 0].<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043c\u0435\u043d\u044f\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u0435\u0440\u0435\u0434\u043d\u0438\u0445 \u043d\u043e\u0433, \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0435\u043c \u0440\u043e\u0431\u043e\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0448\u0430\u0433\u043e\u043c 10-20 \u043c\u043c.<\/p>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 &#8212; [-50, -50, -80, -80], \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [8, 0].<\/p>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 &#8212; [-30, -30, -80, -80], \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [14, 0].<\/p>\n<p><strong>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0435\u043c \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443.<\/strong><\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0445 \u043d\u043e\u0433.<\/p>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 &#8212; [-80, -80, -50, -50], \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [-7, 0].<\/p>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 &#8212; [-80, -80, -30, -30], \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [-12, 0].<\/p>\n<p>\u0418 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435, \u043c\u0435\u043d\u044f\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430. <\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/p>\n<pre><code class=\"javascript\">const x_train = [   [0, 0],   [8, 0],   [14, 0],   [-7, 0],   [-12, 0]   \/\/...... \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 ];  const y_train = [   [-80, -80, -80, -80],   [-50, -50, -80, -80],   [-30, -30, -80, -80],   [-80, -80, -50, -50],   [-80, -80, -30, -30],   \/\/...... \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 ];<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><strong>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043a\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">model   .fit(tf.tensor2d(x_train), tf.tensor2d(y_train), {     epochs: 300,     batchSize: 4,     callbacks: {       onEpochEnd(e, l) {         console.log(e, l);       },     },   });<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043a\u043e\u043b\u0431\u044d\u043a <\/p>\n<pre><code class=\"javascript\">onEpochEnd(e, l) {         console.log(e, l);       },<\/code><\/pre>\n<p>\u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043b\u043e\u0433\u0430\u0445 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043f\u043e\u0442\u0435\u0440\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0418 \u0442\u0430\u043a, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442 <code>node model.js<\/code><\/p>\n<p>\u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043b\u043e\u0433\u0438:<\/p>\n<pre><code>Epoch 298 \/ 300 eta=0.0 ===========================================================>  22ms 1380us\/step - loss=245.84  297 { loss: 245.83786010742188 } Epoch 299 \/ 300 eta=0.0 ===========================================================>  23ms 1466us\/step - loss=245.56  298 { loss: 245.56163024902344 } Epoch 300 \/ 300 eta=0.0 ===========================================================>  23ms 1457us\/step - loss=245.76  299 { loss: 245.76048278808594 }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, <code>loss<\/code> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439. \u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442 &#8212; \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044e \u0438\u0445, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437:<\/p>\n<pre><code class=\"javascript\">const x_train = [   [0, 0],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [0, 0],   [8, 0],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [8, 0],   [14, 0],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [14, 0],   [-7, 0],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-7, 0],   [-12, 0]   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-12, 0]   \/\/...... \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 ];  const y_train = [   [-80, -80, -80, -80],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-80, -80, -80, -80],   [-50, -50, -80, -80],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-50, -50, -80, -80],   [-30, -30, -80, -80],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-30, -30, -80, -80],   [-80, -80, -50, -50],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-80, -80, -50, -50],   [-80, -80, -30, -30],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-80, -80, -30, -30],   \/\/...... \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 ];<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043b\u043e\u0433\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>296 { loss: 0.3628617525100708 } Epoch 298 \/ 300 eta=0.0 ===========================================================>  61ms 358us\/step - loss=0.363  297 { loss: 0.3628309965133667 } Epoch 299 \/ 300 eta=0.0 ===========================================================>  57ms 338us\/step - loss=0.364  298 { loss: 0.36354658007621765 } Epoch 300 \/ 300 eta=0.0 ===========================================================>  58ms 341us\/step - loss=0.363  299 { loss: 0.3632044792175293 }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"javascript\">model   .fit(tf.tensor2d(x_train), tf.tensor2d(y_train), {     epochs: 300,     batchSize: 4,     callbacks: {       onEpochEnd(e, l) {         console.log(e, l);       },     },   }).then(() => model.save('file:\/\/model-js'));<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0430 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/894\/fa2\/6de\/894fa26de19301df670af15bec5dd226.png\" alt=\"\u0424\u0430\u0439\u043b\u044b \u043c\u043e\u0434\u0435\u043b\u0438\" title=\"\u0424\u0430\u0439\u043b\u044b \u043c\u043e\u0434\u0435\u043b\u0438\" width=\"708\" height=\"188\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/894\/fa2\/6de\/894fa26de19301df670af15bec5dd226.png\"\/><\/p>\n<div><figcaption>\u0424\u0430\u0439\u043b\u044b \u043c\u043e\u0434\u0435\u043b\u0438<\/figcaption><\/div>\n<\/figure>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c<\/h2>\n<p>\u041d\u0430\u0441\u0442\u0430\u043b\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u043e\u0433 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u0433\u043b\u043e\u0432. \u0414\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">const tf = require(\"@tensorflow\/tfjs-node\");  async function initModel() {   const model = await tf.loadLayersModel(\"file:\/\/model-js\/model.json\");   return model; }  initModel().then(model => { \/\/\/\/\/\/\/ \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043d\u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 X \u0438 Y const result = model.predict(tf.tensor2d([[X, Y]])).dataSync(); });<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>model.predict()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043d\u043e\u0433. <br \/>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c &#8212; \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0443\u0433\u043b\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0445 \u0432 <code>model.predict()<\/code>. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442,  \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043d\u043e\u0433 \u0440\u043e\u0431\u043e\u0442\u0430.<\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a  &#8212; <\/p>\n<pre><code class=\"javascript\">const tf = require(\"@tensorflow\/tfjs-node\");  async function initModel() {   const model = await tf.loadLayersModel(\"file:\/\/model-js\/model.json\");   return model; }  initModel().then(model => {   setInterval(async () => {     const { X, Y } = await gyroScope.getData();     const result = await model.predict(tf.tensor2d([X, Y])).dataSync();      leftArm.setCoords(defaultX, result[0], defaultZ);     rightArm.setCoords(defaultX, result[1], defaultZ);     leftArmBack.setCoords(defaultX, result[2], defaultZ);     rightArmBack.setCoords(defaultX, result[3], defaultZ);   }, 30); });<\/code><\/pre>\n<p><em>(\u0417\u0434\u0435\u0441\u044c \u044f \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 gyroScope \u0438 leftArm, rightArm, leftArmBack, rightArmBack)<\/em><\/p>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435! \u0422\u0435\u043f\u0435\u0440\u044c, \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u044f \u0440\u043e\u0431\u043e\u0442\u0430 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u043e\u0433\u0438.<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/65392a173add7830897d10d1\" data-style=\"\" id=\"65392a173add7830897d10d1\" width=\"\"><\/div>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/65392a613eb8e176bfdfd1aa\" data-style=\"\" id=\"65392a613eb8e176bfdfd1aa\" width=\"\"><\/div>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0418\u0418 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c. \u0422\u0443\u0442 \u0432\u0430\u0436\u043d\u0435\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0448\u0430\u0442\u044c. <\/p>\n<p>\u0412 \u043c\u043e\u0438\u0445 \u043f\u043b\u0430\u043d\u0430\u0445 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u0430.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/769958\/\"> https:\/\/habr.com\/ru\/articles\/769958\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432 \u043e\u0431\u043e \u043c\u043d\u0435: \u043c\u043e\u0435 \u0445\u043e\u0431\u0431\u0438 \u044d\u0442\u043e \u0440\u043e\u0431\u043e\u0442\u043e\u0442\u0435\u0445\u043d\u0438\u043a\u0430. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u0441 \u0448\u0430\u0433\u0430\u044e\u0449\u0438\u043c \u0440\u043e\u0431\u043e\u0442\u043e\u043c \u043d\u0430 \u0431\u0430\u0437\u0435 SunFounder PiCrawler. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u043c\u0430 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430 (\u0418\u0418) \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u0443\u0436\u0438\u0442 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u0432 &#8212; \u043e\u043d\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043c\u043e\u0449\u043d\u0435\u0435 \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u0435\u0435.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0418\u0418 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 TensorFlow.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>PiCrawler<\/figcaption><\/div>\n<\/figure>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0418\u0418 ?<\/h2>\n<p>\u041a\u0440\u0430\u0442\u043a\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 &#8212; \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0418\u0418 \u043c\u044b \u0440\u0435\u0448\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0438 \u043a\u0430\u043a\u0438\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435. \u041f\u043e\u0442\u043e\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0431\u0443\u0434\u044c \u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435 \u0438 &#171;\u0442\u0440\u0435\u043d\u0438\u0440\u0443\u0435\u043c&#187; \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0440\u043e\u0431\u043e\u0442\u0435 PiCrawler<\/h2>\n<p>\u042d\u0442\u043e \u0434\u0435\u0432\u0430\u0439\u0441, \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 AliExpress. \u0414\u043b\u044f \u0435\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 Raspberry Pi 4. \u0420\u043e\u0431\u043e\u0442 \u0438\u043c\u0435\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u043d\u043e\u0433\u0438, \u043f\u043b\u0430\u0442\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0443\u044e \u043f\u043e i2c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443, \u043a\u0430\u043c\u0435\u0440\u0443, \u0443\u043b\u044c\u0442\u0440\u0430\u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u0434\u0430\u0442\u0447\u0438\u043a \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u044b\u0445\u043e\u0434\u044b. <\/p>\n<p>\u042f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u043a \u044d\u0442\u043e\u043c\u0443 \u0440\u043e\u0431\u043e\u0442\u0443 \u043c\u0438\u043d\u0438-\u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f WT901 (\u043c\u043e\u0436\u043d\u043e \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439), \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u043e\u043c \u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u0435 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439 \u043f\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 i2c. \u0418\u043c\u0435\u0435\u0442\u0441\u044f \u041f\u041e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0433\u0430\u043c\u0438.<\/p>\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u0432\u043e\u0437\u044c\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c &#8212; \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u0433\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u043e\u043f\u043e\u0440\u043d\u043e\u0439 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u043e\u0431\u043e\u0442\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f, \u0441 \u043d\u0435\u0433\u043e \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 <code>x, y<\/code> \u0438 \u0443\u0436\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u043e\u0433 <code>y1, y2, y3, y4<\/code>, <\/p>\n<p>\u0433\u0434\u0435 <code>x, y, y1, y2, y3, y4<\/code> &#8212; \u0447\u0438\u0441\u043b\u0430.<\/p>\n<p>API \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Tensor-\u044b &#8212; \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f. <\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 <code>[x, y]<\/code>, \u0430 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 <code>[y1, y2, y3, y4]<\/code><\/p>\n<p>\u0412 \u0432\u0438\u0434\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u044d\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"\"><\/figure>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438 TensorFlow<\/h2>\n<p>\u0418 \u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>[x, y]<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>[y1, y2, y3, y4]<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0436\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e layers-\u043c\u043e\u0434\u0435\u043b\u044c \u0432 Tensorflow &#8212; \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 &#8212; \u044d\u0442\u043e <code>inputShape: [2]<\/code>, \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 &#8212; <code>units: 4<\/code> \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">const tf = require(\"@tensorflow\/tfjs-node\"); const model = tf.sequential();  model.add(tf.layers.dense({ inputShape: [2], units: 32, activation: \"relu\" })); model.add(tf.layers.dense({ units: 32, activation: \"relu6\" })); model.add(tf.layers.dense({ units: 32, activation: \"relu6\" })); model.add(tf.layers.dense({ units: 4, activation: \"relu\" }));  model.summary(); model.compile({   optimizer: tf.train.sgd(0.0001),   loss: \"meanSquaredError\", });<\/code><\/pre>\n<p>\u0418 \u0442\u0430\u043a, \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0433\u043e\u0442\u043e\u0432\u0430! \u041d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438?<\/p>\n<h2>\u0421\u0431\u043e\u0440 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/h2>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435? \u042d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0438\u0445 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439. \u0417\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. <\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c? \u042d\u0442\u043e \u0432\u0441\u0435 \u0442\u0435 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438 &#8212; \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0423 \u0434\u043b\u044f \u043d\u043e\u0433 \u0440\u043e\u0431\u043e\u0442\u0430. \u041d\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 \u0440\u043e\u0431\u043e\u0442\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 &#8212; \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0435\u043c \u0440\u043e\u0431\u043e\u0442, \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u043e\u0433 \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430. \u0422\u0443\u0442 \u0432\u0430\u0436\u043d\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0438 \u0432 \u043a\u0430\u043a\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0435\u0433\u043e \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0442\u044c.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b: <\/p>\n<ul>\n<li>\n<p> <code>gyroScope<\/code> &#8212; \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430. \u041f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>getData()<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>{ X, Y }<\/code> \u0441 \u0443\u0433\u043b\u0430\u043c\u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u0430. <\/p>\n<\/li>\n<li>\n<p><code>leftArm, rightArm, leftArmBack, rightArmBack<\/code> &#8212; \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>setCoords<\/code> \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043d\u043e\u0433 \u0440\u043e\u0431\u043e\u0442\u0430. \u0414\u043b\u044f \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043f\u043e \u043e\u0441\u0438 Y<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0417\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435!<\/strong> <\/p>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e &#8212; \u044d\u0442\u043e \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>Y &#8212; \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 [-80, -80, -80, -80] &#8212; \u0414\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [0, 0].<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043c\u0435\u043d\u044f\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u0435\u0440\u0435\u0434\u043d\u0438\u0445 \u043d\u043e\u0433, \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0435\u043c \u0440\u043e\u0431\u043e\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0448\u0430\u0433\u043e\u043c 10-20 \u043c\u043c.<\/p>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 &#8212; [-50, -50, -80, -80], \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [8, 0].<\/p>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 &#8212; [-30, -30, -80, -80], \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [14, 0].<\/p>\n<p><strong>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0435\u043c \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443.<\/strong><\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0445 \u043d\u043e\u0433.<\/p>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 &#8212; [-80, -80, -50, -50], \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [-7, 0].<\/p>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433 &#8212; [-80, -80, -30, -30], \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 [-12, 0].<\/p>\n<p>\u0418 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435, \u043c\u0435\u043d\u044f\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0433, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430. <\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/p>\n<pre><code class=\"javascript\">const x_train = [   [0, 0],   [8, 0],   [14, 0],   [-7, 0],   [-12, 0]   \/\/...... \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 ];  const y_train = [   [-80, -80, -80, -80],   [-50, -50, -80, -80],   [-30, -30, -80, -80],   [-80, -80, -50, -50],   [-80, -80, -30, -30],   \/\/...... \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 ];<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><strong>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043a\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">model   .fit(tf.tensor2d(x_train), tf.tensor2d(y_train), {     epochs: 300,     batchSize: 4,     callbacks: {       onEpochEnd(e, l) {         console.log(e, l);       },     },   });<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043a\u043e\u043b\u0431\u044d\u043a <\/p>\n<pre><code class=\"javascript\">onEpochEnd(e, l) {         console.log(e, l);       },<\/code><\/pre>\n<p>\u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043b\u043e\u0433\u0430\u0445 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043f\u043e\u0442\u0435\u0440\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0418 \u0442\u0430\u043a, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442 <code>node model.js<\/code><\/p>\n<p>\u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043b\u043e\u0433\u0438:<\/p>\n<pre><code>Epoch 298 \/ 300 eta=0.0 ===========================================================>  22ms 1380us\/step - loss=245.84  297 { loss: 245.83786010742188 } Epoch 299 \/ 300 eta=0.0 ===========================================================>  23ms 1466us\/step - loss=245.56  298 { loss: 245.56163024902344 } Epoch 300 \/ 300 eta=0.0 ===========================================================>  23ms 1457us\/step - loss=245.76  299 { loss: 245.76048278808594 }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, <code>loss<\/code> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439. \u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442 &#8212; \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044e \u0438\u0445, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437:<\/p>\n<pre><code class=\"javascript\">const x_train = [   [0, 0],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [0, 0],   [8, 0],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [8, 0],   [14, 0],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [14, 0],   [-7, 0],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-7, 0],   [-12, 0]   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-12, 0]   \/\/...... \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 ];  const y_train = [   [-80, -80, -80, -80],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-80, -80, -80, -80],   [-50, -50, -80, -80],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-50, -50, -80, -80],   [-30, -30, -80, -80],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-30, -30, -80, -80],   [-80, -80, -50, -50],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-80, -80, -50, -50],   [-80, -80, -30, -30],   \/\/....\u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u044510   [-80, -80, -30, -30],   \/\/...... \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 ];<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043b\u043e\u0433\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>296 { loss: 0.3628617525100708 } Epoch 298 \/ 300 eta=0.0 ===========================================================>  61ms 358us\/step - loss=0.363  297 { loss: 0.3628309965133667 } Epoch 299 \/ 300 eta=0.0 ===========================================================>  57ms 338us\/step - loss=0.364  298 { loss: 0.36354658007621765 } Epoch 300 \/ 300 eta=0.0 ===========================================================>  58ms 341us\/step - loss=0.363  299 { loss: 0.3632044792175293 }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"javascript\">model   .fit(tf.tensor2d(x_train), tf.tensor2d(y_train), {     epochs: 300,     batchSize: 4,     callbacks: {       onEpochEnd(e, l) {         console.log(e, l);       },     },   }).then(() => model.save('file:\/\/model-js'));<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0430 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435:<\/p>\n<figure class=\"bordered full-width\">\n<div><figcaption>\u0424\u0430\u0439\u043b\u044b \u043c\u043e\u0434\u0435\u043b\u0438<\/figcaption><\/div>\n<\/figure>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u043c<\/h2>\n<p>\u041d\u0430\u0441\u0442\u0430\u043b\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u043e\u0433 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u0433\u043b\u043e\u0432. \u0414\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">const tf = require(\"@tensorflow\/tfjs-node\");  async function initModel() {   const model = await tf.loadLayersModel(\"file:\/\/model-js\/model.json\");   return model; }  initModel().then(model => { \/\/\/\/\/\/\/ \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043d\u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 X \u0438 Y const result = model.predict(tf.tensor2d([[X, Y]])).dataSync(); });<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>model.predict()<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043d\u043e\u0433. <br \/>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c &#8212; \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0443\u0433\u043b\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0445 \u0432 <code>model.predict()<\/code>. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442,  \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043d\u043e\u0433 \u0440\u043e\u0431\u043e\u0442\u0430.<\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a  &#8212; <\/p>\n<pre><code class=\"javascript\">const tf = require(\"@tensorflow\/tfjs-node\");  async function initModel() {   const model = await tf.loadLayersModel(\"file:\/\/model-js\/model.json\");   return model; }  initModel().then(model => {   setInterval(async () => {     const { X, Y } = await gyroScope.getData();     const result = await model.predict(tf.tensor2d([X, Y])).dataSync();      leftArm.setCoords(defaultX, result[0], defaultZ);     rightArm.setCoords(defaultX, result[1], defaultZ);     leftArmBack.setCoords(defaultX, result[2], defaultZ);     rightArmBack.setCoords(defaultX, result[3], defaultZ);   }, 30); });<\/code><\/pre>\n<p><em>(\u0417\u0434\u0435\u0441\u044c \u044f \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 gyroScope \u0438 leftArm, rightArm, leftArmBack, rightArmBack)<\/em><\/p>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435! \u0422\u0435\u043f\u0435\u0440\u044c, \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u044f \u0440\u043e\u0431\u043e\u0442\u0430 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u043e\u0433\u0438.<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/65392a173add7830897d10d1\" data-style=\"\" id=\"65392a173add7830897d10d1\" width=\"\"><\/div>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/65392a613eb8e176bfdfd1aa\" data-style=\"\" id=\"65392a613eb8e176bfdfd1aa\" width=\"\"><\/div>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0418\u0418 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c. \u0422\u0443\u0442 \u0432\u0430\u0436\u043d\u0435\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0448\u0430\u0442\u044c. <\/p>\n<p>\u0412 \u043c\u043e\u0438\u0445 \u043f\u043b\u0430\u043d\u0430\u0445 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u0438\u0440\u043e\u0441\u043a\u043e\u043f\u0430 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u0430.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/769958\/\"> https:\/\/habr.com\/ru\/articles\/769958\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-358525","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=358525"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358525\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}