{"id":334608,"date":"2022-06-17T03:00:30","date_gmt":"2022-06-17T03:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=334608"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=334608","title":{"rendered":"<span>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b<\/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><strong>\u041a\u0430\u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e TensorFlow<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/55c\/a61\/533\/55ca61533212ccb45708b232b9f15300.png\" width=\"700\" height=\"467\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/55c\/a61\/533\/55ca61533212ccb45708b232b9f15300.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0432 \u043f\u043b\u0430\u043d\u0435 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u043c \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043e\u0442 \u0434\u043e\u043a\u0442\u043e\u0440\u0430 \u0420\u043e\u0431\u0435\u0440\u0442\u0430 \u041a\u044e\u0431\u043b\u0435\u0440\u0430 \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u043a \u0441\u0442\u0430\u0440\u0442\u0443 <a href=\"https:\/\/skillfactory.ru\/data-scientist-pro?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=data-science_dspr_170622&amp;utm_term=lead\"><u>\u0444\u043b\u0430\u0433\u043c\u0430\u043d\u0441\u043a\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0430 \u043f\u043e Data Science<\/u><\/a>.<\/p>\n<hr\/>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u043a\u043e\u0434 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"python\">import numpy as np np.random.seed(0) X = np.random.randn(1000, 900) y = 2*X[:, 0] + 1 + 0.1*np.random.randn(1000)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 (X, y) \u0438\u0437 1000 \u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0438 900 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 x\u2080, \u2026, x\u2088\u2089\u2089 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439. \u0417\u0430\u0434\u0430\u0447\u0430 \u2014 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f y = 2x\u2080 + 1. \u041f\u043e\u0433\u0440\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u043b\u0430\u044f, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f r\u00b2, \u0431\u043b\u0438\u0437\u043a\u043e\u0433\u043e \u043a 1. \u0418 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<pre><code class=\"python\">from sklearn.linear_model import LinearRegression from sklearn.model_selection import cross_val_score print(cross_val_score(LinearRegression(), X, y)) # Output: # [0.88558154 0.87775961 0.87564832 0.86230888 0.8796105 ]<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 r\u00b2 \u043d\u0430 \u043d\u0435\u043e\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0432\u043d\u043e ~0,87. \u042d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 1. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0435\u0449\u0451 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0436\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"python\">print(cross_val_score(LinearRegression(), X[:, :10], y)) # Output: # [0.99701015 0.99746395 0.99780414 0.99752536 0.99745693]<\/code><\/pre>\n<p>\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e ~0,997%, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0437\u0430\u043f\u043e\u043b\u043e\u043d\u0438\u0442\u044c \u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u0430\u043a \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f. \u0418 \u0432\u043e\u0442 \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 (\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c y) \u0438\u043b\u0438 \u043e\u0446\u0435\u043d\u043a\u0430 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u0438 (\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0443 p-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438\u0437 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0428\u0435\u043f\u043b\u0438 \u0438 \u0442. \u0434.);<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Principal_component_analysis\">\u043c\u0435\u0442\u043e\u0434 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/a> (\u0434\u0430\u043b\u0435\u0435 \u2014 PCA), \u0433\u0434\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0434\u0430\u043d\u043d\u044b\u0445 X \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 W) \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0441 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d <code>y<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0434\u0435\u0441\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431, \u0433\u0434\u0435 PCA \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u043e\u0431\u043e\u0431\u0449\u0430\u0435\u0442\u0441\u044f \u2014 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Kernel_principal_component_analysis\">PCA <\/a>\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044f\u0434\u0440\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u0448\u0443\u0447\u0443! \u0418 \u0433\u043e\u0432\u043e\u0440\u044e \u044f \u043e\u0431 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430\u0445, \u0445\u043e\u0442\u044f PCA \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044f\u0434\u0440\u0430 \u2014 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<h2>\u0410\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b<\/h2>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b, \u043d\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0442\u0435\u0440\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438:\u00a0<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0441\u043e\u0442\u0430 \u0432 \u0441\u0430\u043d\u0442\u0438\u043c\u0435\u0442\u0440\u0430\u0445;\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0441\u043e\u0442\u0430 \u0432 \u043c\u0435\u0442\u0440\u0430\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u043e \u0435\u0441\u043b\u0438 \u0448\u0443\u043c \u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0439, \u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u044d\u0442\u043e \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u0437\u043d\u0430\u043a.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d, \u043d\u043e \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442 \u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u044e\u0442 \u0438 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0443\u044e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c: \u043c\u044b \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0443\u0437\u043a\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0432 \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430\u044f, \u0430 \u043d\u0435 \u0432\u0430\u0436\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 x \u0438 x\u2019.<\/p>\n<h2>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 \u043c\u043d\u0435 \u043d\u0430\u0439\u0442\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u043d\u043e \u044f \u043f\u043e\u043c\u043e\u0433\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0432 \u043d\u0451\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f. \u0410\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2014 \u044d\u0442\u043e e \u2014 encoder \u0438 d \u2014 decoder:<\/p>\n<ul>\n<li>\n<p>e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 x \u0438\u0437 n \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c z \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c m \u2264 n. \u0412\u0435\u043a\u0442\u043e\u0440 z \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0441\u043a\u0440\u044b\u0442\u044b\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c x.<\/p>\n<\/li>\n<li>\n<p>d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043a\u0440\u044b\u0442\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 z \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 x\u2019 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e n.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b x \u0438 x\u2019 \u0431\u044b\u043b\u0438 \u0431\u043b\u0438\u0437\u043a\u0438, \u0434\u043e x \u2248 x\u2019. \u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439:<\/p>\n<blockquote>\n<p>\u041d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 x \u0432 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0435 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f, \u0430 \u0432 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0435 \u2014 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u041f\u0440\u0438 \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0435 \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f x \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c:<\/p>\n<\/blockquote>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b53\/711\/de2\/b53711de216782d47108132783889798.png\" width=\"1400\" height=\"1099\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b53\/711\/de2\/b53711de216782d47108132783889798.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u0440\u0445\u0438\u0432\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 zip \u0438 rar, \u043d\u043e \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c x = x\u2019. \u0424\u043e\u0440\u043c\u0430\u0442\u044b \u0441\u0436\u0430\u0442\u0438\u044f jpeg \u0438 mp3 \u2014 \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438, \u043d\u043e \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438, \u0447\u0442\u043e\u0431\u044b \u043b\u044e\u0434\u0438 \u043d\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043a\u043e\u0433\u0434\u0430 \u0441\u0436\u0430\u0442\u0438\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u043e\u0435, \u0442. \u0435. \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 m.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e?<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u2014 \u044d\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0440\u043e\u0448\u043e, \u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 PCA \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u041d\u043e PCA \u2014 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0435\u0433\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430. \u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/97c\/9cd\/5cf\/97c9cd5cfc2f80813e81221b53979724.png\" width=\"1400\" height=\"1037\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/97c\/9cd\/5cf\/97c9cd5cfc2f80813e81221b53979724.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043d\u0438\u0437\u0443 \u0441\u043b\u0435\u0432\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 (\u0432\u043c\u0435\u0441\u0442\u043e \u0434\u0432\u0443\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0437\u0434\u0435\u0441\u044c \u043e\u0434\u043d\u043e), \u0430 \u0432 \u043d\u0438\u0436\u043d\u0435\u043c \u043f\u0440\u0430\u0432\u043e\u043c \u2014 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438, \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0432\u0443\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u0445. \u041e\u0431\u0430 \u0432\u0435\u0440\u0445\u043d\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u043b\u0438\u0437\u043a\u0438 \u043a \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u043c\u0443 \u043f\u043e\u0434\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443, \u0442\u043e \u0435\u0441\u0442\u044c \u043a \u043b\u0438\u043d\u0438\u0438, \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e m, \u0442\u043e PCA \u0441 m \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e.\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438:<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fff\/963\/10e\/fff96310eebd6608cfba30913ced3965.png\" width=\"1400\" height=\"1046\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fff\/963\/10e\/fff96310eebd6608cfba30913ced3965.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u2014 \u0443\u0437\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u044b \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435! \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0449\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439.<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0440\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430\u0445, \u043d\u043e \u0438\u043c\u0438 \u0432\u044b\u0431\u043e\u0440 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f: \u0441 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430\u043c\u0438 \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0451. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/towardsdatascience.com\/building-a-simple-auto-encoder-via-decision-trees-28ba9342a349\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a> \u0432\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u044d\u043a\u0437\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0430 \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430\u043c\u0438.<\/p>\n<h2>\u0410\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u043d\u0430 Tensorflow<\/h2>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 X \u0441 4 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438:<\/p>\n<pre><code>import tensorflow as tf tf.random.set_seed(0) # keep things reproducible Z = tf.random.uniform(shape=(10000, 1), minval=-5, maxval=5) X = tf.concat([Z**2, Z**3, tf.math.sin(Z), tf.math.exp(Z)], 1)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u041a\u0430\u043a \u0438 \u0434\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c X?\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f X \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432?<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u0435\u043d \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u2014 \u044d\u0442\u043e Z. X \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0435\u043c Z, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 X \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a Z.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0442. \u0435. \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0438\u0437 x = (z\u00b2, z\u00b3, sin(z), exp(z)) \u0432 z. \u0414\u0435\u043a\u043e\u0434\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e z \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 x\u2019 = (z\u00b2, z\u00b3, sin(z), exp(z)).<\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0432\u043e\u0442 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b? \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a X \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 Z. \u041d\u043e \u0432 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0435 \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e; \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 x = (z\u00b2, z\u00b3, sin(z), exp(z)) \u0432 z &#8212; 3. \u0410 \u0434\u0435\u043a\u043e\u0434\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0441 \u0442\u0435\u043c \u0436\u0435 \u0443\u0441\u043f\u0435\u0445\u043e\u043c \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u0441 \u043e\u0434\u043d\u0438\u043c-\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"python\">class AutoEncoder(tf.keras.Model):     def __init__(self):         super().__init__()                  self.encoder = tf.keras.Sequential([             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(1), # compress into 1 dimension         ])         self.decoder = tf.keras.Sequential([             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(4), # unpack into 4 dimensions         ])     def call(self, x):         latent_x = self.encoder(x) # compress         decoded_x = self.decoder(latent_x) # unpack         return decoded_x tf.random.set_seed(0) # keep things reproducible ae = AutoEncoder() ae.compile(     optimizer=tf.keras.optimizers.Adam(learning_rate=0.0001),     loss='mse' ) ae.fit(     X, # input     X, # equals output     validation_split=0.2, # prevent overfitting     epochs=1000,     callbacks=[         tf.keras.callbacks.EarlyStopping(patience=10) # early stop     ] ) # Output: # ... # Epoch 69\/1000 # 250\/250 [==============================] - 0s 1ms\/step - loss:          # 0.0150 - val_loss: 0.0276<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0446\u0438\u0444\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435! \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0435:<\/p>\n<pre><code class=\"python\">print(tf.reduce_max(tf.math.abs(X-ae(X)))) # Output: # tf.Tensor(0.89660645, shape=(), dtype=float32)<\/code><\/pre>\n<p>\u041d\u0435\u043f\u043b\u043e\u0445\u043e, \u0435\u0441\u043b\u0438 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438\u0441\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0442\u043d\u044f\u043c\u0438. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u0435-\u0447\u0442\u043e \u043f\u043e\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435.<\/p>\n<h2>\u0421\u0436\u0430\u0442\u0438\u0435 \u0447\u0438\u0441\u0435\u043b<\/h2>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c MNIST \u2014 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0446\u0438\u0444\u0440:<\/p>\n<pre><code class=\"python\">(X_train, _), (X_test, _) = tf.keras.datasets.mnist.load_data() X_train = X_train.reshape(-1, 28, 28, 1) \/ 255. # value range=[0,1] X_test = X_test.reshape(-1, 28, 28, 1) \/ 255.   # shape=(28, 28, 1)<\/code><\/pre>\n<p>\u0418\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0435\u043b:<\/p>\n<pre><code class=\"python\">import matplotlib.pyplot as plt for i in range(3):     plt.imshow(X_train[i])     plt.show()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/180\/8e7\/11e\/1808e711e859220607d2fafd2bebe10e.png\" width=\"251\" height=\"248\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/180\/8e7\/11e\/1808e711e859220607d2fafd2bebe10e.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a71\/988\/be5\/a71988be549e28e9f77c6f7ac80c15e7.png\" width=\"251\" height=\"248\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a71\/988\/be5\/a71988be549e28e9f77c6f7ac80c15e7.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f93\/394\/25f\/f9339425f78bbe3fcb99c5670d9254a1.png\" width=\"251\" height=\"248\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f93\/394\/25f\/f9339425f78bbe3fcb99c5670d9254a1.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0446\u0438\u0444\u0440 28 x 28 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u2014 \u043f\u0440\u0438\u0437\u043d\u0430\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043d\u0430\u0441 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 28 * 28 = 784 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440. \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0420\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0435 \u0446\u0438\u0444\u0440\u044b \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 28 x 28 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0423 \u0446\u0438\u0444\u0440 \u0432\u0435\u0441\u044c\u043c\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f 28 x 28 \u2014 \u044d\u0442\u043e \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0446\u0438\u0444\u0440\u044b:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fe1\/4a4\/365\/fe14a4365d62f823bf8aaaab43a243ee.png\" width=\"251\" height=\"248\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fe1\/4a4\/365\/fe14a4365d62f823bf8aaaab43a243ee.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1c5\/ac2\/790\/1c5ac27904b424db09c4b92957bd7936.png\" width=\"251\" height=\"248\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1c5\/ac2\/790\/1c5ac27904b424db09c4b92957bd7936.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d15\/349\/5df\/d153495df953dd9021a2fe8a973ddbbb.png\" width=\"251\" height=\"248\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d15\/349\/5df\/d153495df953dd9021a2fe8a973ddbbb.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c MNIST? \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043e\u0431\u0449\u0435\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u043c, \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0442\u0440\u0435\u043c\u044f\u0442\u0441\u044f \u043a \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u043d\u043e \u0441\u043e \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u044f\u043c\u0438. \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u0434\u0435\u043b\u0443.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432\u0430\u0440\u044c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0442 0 \u0434\u043e 1 \u2014 \u0442\u0430\u043a \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0435\u0435, \u0430 \u0444\u043e\u0440\u043c\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (28, 28, 1) \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432:<\/p>\n<pre><code>from tensorflow.keras import layers class ConvolutionalAutoEncoder(tf.keras.Model):     def __init__(self):         super().__init__()                  self.encoder = tf.keras.Sequential([             layers.Conv2D(4, 5, activation='relu'),             layers.Conv2D(4, 5, activation='relu'),             layers.Conv2D(1, 5, activation='relu'),         ])         self.decoder = tf.keras.Sequential([             layers.Conv2DTranspose(4, 5, activation='relu'),             layers.Conv2DTranspose(4, 5, activation='relu'),             layers.Conv2DTranspose(1, 5, activation='sigmoid'),         ])     def call(self, x):         latent_x = self.encoder(x)         decoded_x = self.decoder(latent_x)         return decoded_x tf.random.set_seed(0) ae = ConvolutionalAutoEncoder() ae.compile(optimizer='adam', loss='bce') ae.fit(     X_train,      X_train,     batch_size=128,     epochs=1000,     validation_data=(X_test, X_test),     callbacks=[         tf.keras.callbacks.EarlyStopping(patience=1)     ] ) # Output: # ... # Epoch 12\/1000 # 469\/469 [==============================] - 91s 193ms\/step - loss: # 0.0815 - val_loss: 0.0813<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u043b\u0438\u043a\u043e \u0441\u043a\u0440\u044b\u0442\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e:<\/p>\n<pre><code class=\"python\">print(ae.summary())<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0430 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u044f, \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 (None, 16, 16, 1), \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 16 * 16 * 1 = 256 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 16 x 16 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0441 \u043e\u0434\u043d\u0438\u043c \u043a\u0430\u043d\u0430\u043b\u043e\u043c.<\/p>\n<blockquote>\n<p>\u0412 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f bce (\u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043a\u0440\u043e\u0441\u0441-\u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044f), \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043a 0 \u0438\u043b\u0438 1. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0441\u043b\u043e\u0435 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0441\u0438\u0433\u043c\u043e\u0438\u0434\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438. \u0418\u0437-\u0437\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f MSE \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0447\u0430\u0441\u0442\u043e \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u043a\u043e\u043b\u043e 0,5.<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432\u0440\u0443\u0447\u043d\u0443\u044e:<\/p>\n<pre><code class=\"python\">decoded_images = ae.predict(X_test[:10]) latent_images = ae.encoder(X_test[:10]) plt.figure(figsize=(20, 4)) for i in range(10):     ax = plt.subplot(3, n, i + 1)     plt.imshow(X_test[i])     ax.get_xaxis().set_visible(False)     ax.get_yaxis().set_visible(False)          ax = plt.subplot(3, n, i + 1 + n)     plt.imshow(latent_images[i] \/ tf.reduce_max(latent_images[i]))     ax.get_xaxis().set_visible(False)     ax.get_yaxis().set_visible(False)     ax = plt.subplot(3, n, i + 1 + 2*n)     plt.imshow(decoded_images[i])     ax.get_xaxis().set_visible(False)     ax.get_yaxis().set_visible(False)      plt.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dd6\/906\/fc3\/dd6906fc34796059ac3e9cb2ee410a64.png\" alt=\"\u0421\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437: \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435, \u0441\u0436\u0430\u0442\u044b\u0435, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435\" title=\"\u0421\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437: \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435, \u0441\u0436\u0430\u0442\u044b\u0435, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435\" width=\"1103\" height=\"235\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dd6\/906\/fc3\/dd6906fc34796059ac3e9cb2ee410a64.png\"\/><figcaption>\u0421\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437: \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435, \u0441\u0436\u0430\u0442\u044b\u0435, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435<\/figcaption><\/figure>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e! \u041a\u043e\u0435-\u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0432\u043e\u0439\u043a\u043e\u0439, \u043d\u043e \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0451 \u043f\u043e\u043b\u0443\u0447\u0448\u0435. \u0421\u043a\u0440\u044b\u0442\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0446\u0438\u0444\u0440\u044b, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c: 16 x 16 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0430 \u043d\u0435 28 x 28. \u0422\u0430\u043a \u0441\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430. \u0412 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0435 \u0442\u0430\u043a\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c.<\/p>\n<p>\u042f \u043d\u0430\u0445\u043e\u0436\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438: \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0446\u0438\u0444\u0440 \u2014 \u0442\u0430\u043a, \u0447\u0442\u043e \u0438\u043c\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0451 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u041a\u0430\u043a \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u044f, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0442\u043e\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u0431\u044b \u0442\u0430\u043a, \u0430 \u0437\u0434\u0435\u0441\u044c \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439.<\/p>\n<h3>\u0414\u0440\u0443\u0433\u0438\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b<\/h3>\n<p>\u041c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0432\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c: \u043c\u0435\u043d\u044f\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430, \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b \u0434\u043e\u043b\u0433\u043e\u0439 \u043a\u0440\u0430\u0442\u043a\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (LSTM) \u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b \u0442\u0438\u043f\u0430 \u00ab\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c-\u0432-\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438\u00bb, \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b-\u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u044b \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b \u0448\u0442\u0440\u0430\u0444\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0437\u0430 \u0441\u0447\u0451\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a \u0441\u043b\u043e\u044e (\u0441\u043b\u043e\u044f\u043c) \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 activity_regularizer.<\/p>\n<p>\u041d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435: \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u043a\u0430\u043a \u0432 \u043a\u0440\u0438\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0438\u0430\u043b\u0435 (\u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e!):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f8\/b6f\/976\/5f8b6f976dae01e5b44f08ecfcc552d0.gif\" width=\"624\" height=\"349\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5f8\/b6f\/976\/5f8b6f976dae01e5b44f08ecfcc552d0.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u0442\u00f3\u044f\u0449\u0438\u0439 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u2014 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u044d\u043d\u043a\u043e\u0434\u0435\u0440. \u041e\u043d \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c, \u043d\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/178\/f78\/bc5\/178f78bc520f5d8c00a9af4ac49eef40.jpeg\" alt=\"https:\/\/www.tensorflow.org\/tutorials\/generative\/cvae\" title=\"https:\/\/www.tensorflow.org\/tutorials\/generative\/cvae\" width=\"557\" height=\"558\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/178\/f78\/bc5\/178f78bc520f5d8c00a9af4ac49eef40.jpeg\" data-blurred=\"true\"\/><figcaption>https:\/\/www.tensorflow.org\/tutorials\/generative\/cvae<\/figcaption><\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438, \u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043d\u0438\u0437\u0438\u0442\u044c\u0441\u044f. \u0414\u0435\u043b\u043e \u0447\u0430\u0441\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u0430\u043a PCA.<\/p>\n<p>\u041d\u043e \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438, \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445; \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0433\u0443\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b, \u0433\u0434\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0434\u043e \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b, \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u0443 \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<p>\u0410 \u043c\u044b \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u0432\u0430\u043c \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c \u043d\u0430\u0432\u044b\u043a\u0438 \u0438\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e, \u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432 \u043b\u044e\u0431\u043e\u0435 \u0432\u0440\u0435\u043c\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/data-scientist-pro?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=data-science_dspr_170622&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Scientist<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/python-fullstack-web-developer?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=coding_fpw_170622&amp;utm_term=conc\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Fullstack-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Python<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e <a href=\"https:\/\/skillfactory.ru\/concalogue?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=sf_allcourses_170622&amp;utm_term=conc\">\u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e<\/a>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3be\/289\/4b6\/3be2894b60d07408256f0d63a0f1a782.png\" width=\"1000\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3be\/289\/4b6\/3be2894b60d07408256f0d63a0f1a782.png\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/company\/skillfactory\/blog\/671864\/\"> https:\/\/habr.com\/ru\/company\/skillfactory\/blog\/671864\/<\/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><strong>\u041a\u0430\u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e TensorFlow<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0432 \u043f\u043b\u0430\u043d\u0435 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u043c \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043e\u0442 \u0434\u043e\u043a\u0442\u043e\u0440\u0430 \u0420\u043e\u0431\u0435\u0440\u0442\u0430 \u041a\u044e\u0431\u043b\u0435\u0440\u0430 \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u043a \u0441\u0442\u0430\u0440\u0442\u0443 <a href=\"https:\/\/skillfactory.ru\/data-scientist-pro?utm_source=habr&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=data-science_dspr_170622&amp;utm_term=lead\"><u>\u0444\u043b\u0430\u0433\u043c\u0430\u043d\u0441\u043a\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0430 \u043f\u043e Data Science<\/u><\/a>.<\/p>\n<hr\/>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u043a\u043e\u0434 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"python\">import numpy as np np.random.seed(0) X = np.random.randn(1000, 900) y = 2*X[:, 0] + 1 + 0.1*np.random.randn(1000)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 (X, y) \u0438\u0437 1000 \u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0438 900 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 x\u2080, \u2026, x\u2088\u2089\u2089 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439. \u0417\u0430\u0434\u0430\u0447\u0430 \u2014 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f y = 2x\u2080 + 1. \u041f\u043e\u0433\u0440\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u043b\u0430\u044f, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f r\u00b2, \u0431\u043b\u0438\u0437\u043a\u043e\u0433\u043e \u043a 1. \u0418 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<pre><code class=\"python\">from sklearn.linear_model import LinearRegression from sklearn.model_selection import cross_val_score print(cross_val_score(LinearRegression(), X, y)) # Output: # [0.88558154 0.87775961 0.87564832 0.86230888 0.8796105 ]<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 r\u00b2 \u043d\u0430 \u043d\u0435\u043e\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0432\u043d\u043e ~0,87. \u042d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 1. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0435\u0449\u0451 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0436\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"python\">print(cross_val_score(LinearRegression(), X[:, :10], y)) # Output: # [0.99701015 0.99746395 0.99780414 0.99752536 0.99745693]<\/code><\/pre>\n<p>\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e ~0,997%, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0437\u0430\u043f\u043e\u043b\u043e\u043d\u0438\u0442\u044c \u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u0430\u043a \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f. \u0418 \u0432\u043e\u0442 \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 (\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c y) \u0438\u043b\u0438 \u043e\u0446\u0435\u043d\u043a\u0430 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u0438 (\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0443 p-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438\u0437 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0428\u0435\u043f\u043b\u0438 \u0438 \u0442. \u0434.);<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Principal_component_analysis\">\u043c\u0435\u0442\u043e\u0434 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/a> (\u0434\u0430\u043b\u0435\u0435 \u2014 PCA), \u0433\u0434\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (\u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0434\u0430\u043d\u043d\u044b\u0445 X \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 W) \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0441 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d <code>y<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0434\u0435\u0441\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431, \u0433\u0434\u0435 PCA \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u043e\u0431\u043e\u0431\u0449\u0430\u0435\u0442\u0441\u044f \u2014 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Kernel_principal_component_analysis\">PCA <\/a>\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044f\u0434\u0440\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u0448\u0443\u0447\u0443! \u0418 \u0433\u043e\u0432\u043e\u0440\u044e \u044f \u043e\u0431 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430\u0445, \u0445\u043e\u0442\u044f PCA \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044f\u0434\u0440\u0430 \u2014 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<h2>\u0410\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b<\/h2>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b, \u043d\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0442\u0435\u0440\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438:\u00a0<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0441\u043e\u0442\u0430 \u0432 \u0441\u0430\u043d\u0442\u0438\u043c\u0435\u0442\u0440\u0430\u0445;\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0441\u043e\u0442\u0430 \u0432 \u043c\u0435\u0442\u0440\u0430\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u043e \u0435\u0441\u043b\u0438 \u0448\u0443\u043c \u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0439, \u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u044d\u0442\u043e \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u0437\u043d\u0430\u043a.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d, \u043d\u043e \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442 \u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u044e\u0442 \u0438 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0443\u044e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c: \u043c\u044b \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0443\u0437\u043a\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0432 \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430\u044f, \u0430 \u043d\u0435 \u0432\u0430\u0436\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 x \u0438 x\u2019.<\/p>\n<h2>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 \u043c\u043d\u0435 \u043d\u0430\u0439\u0442\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u043d\u043e \u044f \u043f\u043e\u043c\u043e\u0433\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0432 \u043d\u0451\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f. \u0410\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2014 \u044d\u0442\u043e e \u2014 encoder \u0438 d \u2014 decoder:<\/p>\n<ul>\n<li>\n<p>e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 x \u0438\u0437 n \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c z \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c m \u2264 n. \u0412\u0435\u043a\u0442\u043e\u0440 z \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0441\u043a\u0440\u044b\u0442\u044b\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c x.<\/p>\n<\/li>\n<li>\n<p>d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043a\u0440\u044b\u0442\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 z \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 x\u2019 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e n.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b x \u0438 x\u2019 \u0431\u044b\u043b\u0438 \u0431\u043b\u0438\u0437\u043a\u0438, \u0434\u043e x \u2248 x\u2019. \u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439:<\/p>\n<blockquote>\n<p>\u041d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 x \u0432 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0435 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f, \u0430 \u0432 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0435 \u2014 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u041f\u0440\u0438 \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0435 \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f x \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c:<\/p>\n<\/blockquote>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u0440\u0445\u0438\u0432\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 zip \u0438 rar, \u043d\u043e \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c x = x\u2019. \u0424\u043e\u0440\u043c\u0430\u0442\u044b \u0441\u0436\u0430\u0442\u0438\u044f jpeg \u0438 mp3 \u2014 \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438, \u043d\u043e \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438, \u0447\u0442\u043e\u0431\u044b \u043b\u044e\u0434\u0438 \u043d\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043a\u043e\u0433\u0434\u0430 \u0441\u0436\u0430\u0442\u0438\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u043e\u0435, \u0442. \u0435. \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 m.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e?<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u2014 \u044d\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0440\u043e\u0448\u043e, \u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 PCA \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u041d\u043e PCA \u2014 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0435\u0433\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430. \u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043d\u0438\u0437\u0443 \u0441\u043b\u0435\u0432\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 (\u0432\u043c\u0435\u0441\u0442\u043e \u0434\u0432\u0443\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0437\u0434\u0435\u0441\u044c \u043e\u0434\u043d\u043e), \u0430 \u0432 \u043d\u0438\u0436\u043d\u0435\u043c \u043f\u0440\u0430\u0432\u043e\u043c \u2014 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438, \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0432\u0443\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u0445. \u041e\u0431\u0430 \u0432\u0435\u0440\u0445\u043d\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u043b\u0438\u0437\u043a\u0438 \u043a \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u043c\u0443 \u043f\u043e\u0434\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443, \u0442\u043e \u0435\u0441\u0442\u044c \u043a \u043b\u0438\u043d\u0438\u0438, \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e m, \u0442\u043e PCA \u0441 m \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e.\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438:<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u2014 \u0443\u0437\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u044b \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u044b \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435! \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0449\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439.<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0440\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430\u0445, \u043d\u043e \u0438\u043c\u0438 \u0432\u044b\u0431\u043e\u0440 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f: \u0441 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430\u043c\u0438 \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0451. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/towardsdatascience.com\/building-a-simple-auto-encoder-via-decision-trees-28ba9342a349\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a> \u0432\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u044d\u043a\u0437\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0430 \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430\u043c\u0438.<\/p>\n<h2>\u0410\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u043d\u0430 Tensorflow<\/h2>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 X \u0441 4 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438:<\/p>\n<pre><code>import tensorflow as tf tf.random.set_seed(0) # keep things reproducible Z = tf.random.uniform(shape=(10000, 1), minval=-5, maxval=5) X = tf.concat([Z**2, Z**3, tf.math.sin(Z), tf.math.exp(Z)], 1)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u041a\u0430\u043a \u0438 \u0434\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c X?\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f X \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432?<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u0435\u043d \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u2014 \u044d\u0442\u043e Z. X \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0435\u043c Z, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 X \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a Z.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0442. \u0435. \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0438\u0437 x = (z\u00b2, z\u00b3, sin(z), exp(z)) \u0432 z. \u0414\u0435\u043a\u043e\u0434\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e z \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 x\u2019 = (z\u00b2, z\u00b3, sin(z), exp(z)).<\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0432\u043e\u0442 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b? \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a X \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 Z. \u041d\u043e \u0432 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0435 \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e; \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 x = (z\u00b2, z\u00b3, sin(z), exp(z)) \u0432 z &#8212; 3. \u0410 \u0434\u0435\u043a\u043e\u0434\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0441 \u0442\u0435\u043c \u0436\u0435 \u0443\u0441\u043f\u0435\u0445\u043e\u043c \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u0441 \u043e\u0434\u043d\u0438\u043c-\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"python\">class AutoEncoder(tf.keras.Model):     def __init__(self):         super().__init__()                  self.encoder = tf.keras.Sequential([             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(1), # compress into 1 dimension         ])         self.decoder = tf.keras.Sequential([             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(100, activation='relu'),             tf.keras.layers.Dense(4), # unpack into 4 dimensions         ])     def call(self, x):         latent_x = self.encoder(x) # compress         decoded_x = self.decoder(latent_x) # unpack         return decoded_x tf.random.set_seed(0) # keep things reproducible ae = AutoEncoder() ae.compile(     optimizer=tf.keras.optimizers.Adam(learning_rate=0.0001),     loss='mse' ) ae.fit(     X, # input     X, # equals output     validation_split=0.2, # prevent overfitting     epochs=1000,     callbacks=[         tf.keras.callbacks.EarlyStopping(patience=10) # early stop     ] ) # Output: # ... # Epoch 69\/1000 # 250\/250 [==============================] - 0s 1ms\/step - loss:          # 0.0150 - val_loss: 0.0276<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0446\u0438\u0444\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435! \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0435:<\/p>\n<pre><code class=\"python\">print(tf.reduce_max(tf.math.abs(X-ae(X)))) # Output: # tf.Tensor(0.89660645, shape=(), dtype=float32)<\/code><\/pre>\n<p>\u041d\u0435\u043f\u043b\u043e\u0445\u043e, \u0435\u0441\u043b\u0438 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438\u0441\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0442\u043d\u044f\u043c\u0438. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u0435-\u0447\u0442\u043e \u043f\u043e\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435.<\/p>\n<h2>\u0421\u0436\u0430\u0442\u0438\u0435 \u0447\u0438\u0441\u0435\u043b<\/h2>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c MNIST \u2014 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0446\u0438\u0444\u0440:<\/p>\n<pre><code class=\"python\">(X_train, _), (X_test, _) = tf.keras.datasets.mnist.load_data() X_train = X_train.reshape(-1, 28, 28, 1) \/ 255. # value range=[0,1] X_test = X_test.reshape(-1, 28, 28, 1) \/ 255.   # shape=(28, 28, 1)<\/code><\/pre>\n<p>\u0418\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0435\u043b:<\/p>\n<pre><code class=\"python\">import matplotlib.pyplot as plt for i in range(3):     plt.imshow(X_train[i])     plt.show()<\/code><\/pre>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0446\u0438\u0444\u0440 28 x 28 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u2014 \u043f\u0440\u0438\u0437\u043d\u0430\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043d\u0430\u0441 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 28 * 28 = 784 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440. \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0420\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0435 \u0446\u0438\u0444\u0440\u044b \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 28 x 28 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0423 \u0446\u0438\u0444\u0440 \u0432\u0435\u0441\u044c\u043c\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f 28 x 28 \u2014 \u044d\u0442\u043e \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0446\u0438\u0444\u0440\u044b:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c MNIST? \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043e\u0431\u0449\u0435\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u043c, \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0442\u0440\u0435\u043c\u044f\u0442\u0441\u044f \u043a \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u0432\u0442\u043e\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u043d\u043e \u0441\u043e \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u044f\u043c\u0438. \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u0434\u0435\u043b\u0443.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432\u0430\u0440\u044c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0442 0 \u0434\u043e 1 \u2014 \u0442\u0430\u043a \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0435\u0435, \u0430 \u0444\u043e\u0440\u043c\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (28, 28, 1) \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432:<\/p>\n<pre><code>from tensorflow.keras import layers class ConvolutionalAutoEncoder(tf.keras.Model):     def __init__(self):         super().__init__()                  self.encoder = tf.keras.Sequential([             layers.Conv2D(4, 5, activation='relu'),             layers.Conv2D(4, 5, activation='relu'),             layers.Conv2D(1, 5, activation='relu'),         ])         self.decoder = tf.keras.Sequential([             layers.Conv2DTranspose(4, 5, activation='relu'),             layers.Conv2DTranspose(4, 5, activation='relu'),             layers.Conv2DTranspose(1, 5, activation='sigmoid'),         ])     def call(self, x):         latent_x = self.encoder(x)         decoded_x = self.decoder(latent_x)         return decoded_x tf.random.set_seed(0) ae = ConvolutionalAutoEncoder() ae.compile(optimizer='adam', loss='bce') ae.fit(     X_train,      X_train,     batch_size=128,     epochs=1000,     validation_data=(X_test, X_test),     callbacks=[         tf.keras.callbacks.EarlyStopping(patience=1)     ] ) # Output: # ... # Epoch 12\/1000 # 469\/469 [==============================] - 91s 193ms\/step - loss: # 0.0815 - val_loss: 0.0813<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-334608","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334608","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=334608"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334608\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}