{"id":444716,"date":"2025-01-10T21:02:43","date_gmt":"2025-01-10T21:02:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=444716"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=444716","title":{"rendered":"<span>\u041a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d PyTorch. \u0427\u0435\u043c\u0443 \u044f \u043d\u0430\u0443\u0447\u0438\u043b\u0441\u044f, \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 PyTorch \u0431\u0435\u0437 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 Python<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u044f \u0437\u0430\u0434\u0430\u043b \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c micrograd \u043d\u0430 Rust, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u0417\u0430\u043d\u0438\u043c\u0430\u044f\u0441\u044c \u044d\u0442\u0438\u043c, \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0431\u0430\u0437\u0435 micrograd \u043f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u0432. \u042f \u0437\u043d\u0430\u043a\u043e\u043c \u0441 PyTorch \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0430\u0433\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043c\u043d\u0435 \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u043e \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043d\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 Python, \u044d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0432\u0438\u0434\u0435\u043b\u0430\u0441\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. <\/p>\n<p> \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u0432\u043e\u0438\u043b \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u043d \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b \u043c\u0435\u043d\u044f \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e PyTorch \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0443 PyTorch. \u0412\u043e\u0437\u044c\u043c\u0443\u0441\u044c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e, \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044f \u044d\u0442\u0438\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u0438\u0445 \u0437\u0430 \u0447\u0438\u0441\u0442\u0443\u044e \u043c\u043e\u043d\u0435\u0442\u0443, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043d\u0435\u0441\u0442\u0438 \u0432 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0446\u0435\u043b\u0443\u044e \u043a\u0443\u0447\u0443 \u0431\u0430\u0433\u043e\u0432. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d, \u0430 \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u0441\u044f \u0432\u0430\u0448 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0438\u0447\u0435\u043c\u0443 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f<br \/> <a name=\"habracut\"><\/a> <\/p>\n<blockquote><p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 PyTorch, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b. \u0415\u0441\u043b\u0438 \u0447\u0435\u0433\u043e-\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0431\u0443\u0434\u0443 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u041d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u044d\u0442\u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438.<\/p><\/blockquote>\n<p> <\/p>\n<h3>\u0427\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0435 \u0442\u0435\u043d\u0437\u043e\u0440?<\/h3>\n<p> \u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043d\u0437\u043e\u0440 \u2014 \u044d\u0442\u043e n-\u043c\u0435\u0440\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430. \u0425\u043e\u0440\u043e\u0448\u043e, \u0430 \u0447\u0442\u043e \u0436\u0435 \u0442\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u043e\u0435 <code>torch.Tensor<\/code>? \u0422\u043e\u0447\u043d\u0435\u0435, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430:<code> a = torch.tensor(1.0, requires_grad=True)<\/code>. \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e PyTorch \u0432\u044b\u0434\u0435\u043b\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u0443\u0447\u0435 \u0438 \u0432\u0435\u0440\u043d\u0451\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0440\u0438\u0447\u0451\u043c, \u044d\u0442\u043e \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c. \u0427\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0432 PyTorch, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.<\/p>\n<pre><code class=\"python\">a = torch.arange(9).reshape(3, 3) # 3x3 b = a.t() # \u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 b[0, 0] = 9999 a # &gt;&gt; tensor([[9999, 1, 2], [3, 4, 5], [6, 7, 8]])<\/code><\/pre>\n<p> \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0432 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435<code> .t()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0438 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438 <code>a<\/code>, \u0438 <code>b<\/code> \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u0432\u043d\u0435\u0441\u0451\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u043d\u044b \u0441 \u043e\u0431\u043e\u0438\u0445 \u044d\u0442\u0438\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<pre><code class=\"python\">a = torch.arange(9).reshape(3, 3) # torch.int64 b = a.to(torch.float16) b[0][0] = 1000 print(a[0][0].item(), b[0][0].item()) # 0 1000.0<\/code><\/pre>\n<p> \u0410 \u0432\u043e\u0442 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>b<\/code> \u2014 \u0442\u043e\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u043d\u043e \u043e\u043d \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u043d\u0430 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0435\u043d\u0437\u043e\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u0438\u043d\u043e\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e PyTorch \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 <code>float16<\/code> \u0438 <code>int64<\/code>. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, PyTorch \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043f\u043e-\u043d\u043e\u0432\u043e\u043c\u0443.<\/p>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u00ab\u043d\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u00bb \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u044d\u0442\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. <a href=\"https:\/\/pytorch.org\/docs\/stable\/storage.html\">\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 PyTorch<\/a>, \u0432 \u0442\u0435\u043d\u0437\u043e\u0440\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f torch.Storage, \u0438 \u0432 \u043d\u0435\u0439 \u00ab\u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 <code>torch.Tensor<\/code>. \u0422\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0432 \u0442\u0435\u043d\u0437\u043e\u0440\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0438 \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0442.\u0434. \u041c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0433\u043e\u0442\u043e\u0432 \u0441\u043a\u0435\u043b\u0435\u0442, \u043e\u0447\u0435\u0440\u0442\u0430\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0442 <code>torch.Tensor<\/code>.<\/p>\n<p> \u0422\u0430\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0437\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u0435\u0436\u0438\u0442 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 <code>torch.Tensor<\/code>.<\/p>\n<pre><code class=\"python\">struct Tensor { data: torch.Storage. grad: Tensor, grad_fn: BackwardFn .... \/\/ \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 }<\/code><\/pre>\n<p> <\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f <code>torch.Storage<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443. \u0422\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 <code>m = [[1,2],[3,4]]<\/code>. \u041f\u0440\u0438\u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: <\/p>\n<ol>\n<li> \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043b\u044e\u0431\u0443\u044e (\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e) \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0438\u0437-\u0437\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u2014 \u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445.<\/li>\n<li> \u0415\u0449\u0451 \u0432\u0430\u0436\u043d\u0435\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b, \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/li>\n<\/ol>\n<p> \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 2, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 (1,2). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>m[0][1]<\/code>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: <code>m<\/code> \u2014 \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0432\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0412 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043b\u044e\u0431\u044b\u043c n-\u043c\u0435\u0440\u043d\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 n \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443, \u0430 \u044d\u0442\u043e \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p> \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0432\u0441\u0435\u0433\u043e 1 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442? \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u0441\u0445\u0435\u043c\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 (x, y) \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u043d\u0430\u043c \u043b\u0438\u0448\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043f\u043e <code>torch.Storage<\/code>, \u0441\u0430\u043c <code>torch.Storage<\/code> \u2013 \u044d\u0442\u043e \u00ab\u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432\u00bb. \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u043a\u0443\u044e <a href=\"https:\/\/github.com\/nreHieW\/r-nn\/blob\/main\/src\/core\/tensor\/mod.rs#L92\">\u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0443 \u0441\u0445\u0435\u043c\u0443 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 (x, y) (\u0430 \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u2014 \u0438 \u043b\u044e\u0431\u0443\u044e n-\u043c\u0435\u0440\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443), \u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043e\u0431\u044c\u0451\u043c\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p> \u0423 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432. \u0421 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043c\u044b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u043e \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0434\u043e\u0431\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Locality_of_reference\">\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e<\/a>, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u043d\u0430\u043c \u0432 \u043a\u044d\u0448\u0435.<\/p>\n<p> \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0438\u0434\u0430 <code>.reshape()<\/code> \u0438 <code>.view()<\/code>. \u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u044f \u0435\u0451 \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0442\u0430\u0440\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043d\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u044b. \u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f <a href=\"https:\/\/github.com\/nreHieW\/r-nn\/blob\/main\/src\/core\/tensor\/mod.rs#L92\">\u0443\u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/a>, \u0442\u043e \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c <a href=\"https:\/\/github.com\/nreHieW\/r-nn\/blob\/main\/src\/core\/tensor\/mod.rs#L172\">\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0444\u043e\u0440\u043c\u044b<\/a>.<\/p>\n<p> \u0412 <code>r-nn<\/code> \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u044f\u0432\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0443\u044e \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u0441\u0434\u0435\u043b\u0430\u043b \u0442\u0430\u043a \u0434\u043b\u044f \u044f\u0441\u043d\u043e\u0441\u0442\u0438. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443, \u043c\u044b \u043d\u0435\u0441\u0451\u043c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438 \u2014 \u0438 \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0440\u0430\u0432\u044b! \u0412 PyTorch \u0442\u0430\u043a\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <code>stride<\/code>, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0444\u043e\u0440\u043c\u044b \u0442\u0435\u043d\u0437\u043e\u0440\u0430.<\/p>\n<p> \u0412 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u0448\u0430\u0433 (stride) \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. i-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0448\u0430\u0433\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043c\u0443, \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0432\u0434\u043e\u043b\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044c\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e i. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>.transpose()<\/code> PyTorch \u0442\u043e\u043b\u044c\u043a\u043e \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0448\u0430\u0433. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0445\u043e\u0442\u044f \u043c\u044b \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u043e\u0442\u0432\u0435\u0442 \u0442\u0435\u043d\u0437\u043e\u0440 \u0432 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u043d\u0437\u043e\u0440\u0430, \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c\u0438. \u0427\u0442\u043e\u0431\u044b \u0443\u0441\u0432\u043e\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u0437\u0430\u0434\u0443\u043c\u0430\u0439\u0442\u0435\u0441\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<pre><code class=\"python\">x = torch.arange(9).reshape(3, 3) # 3 x 3 x.t().view(1, -1) # \u0423\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043d\u0437\u043e\u0440\u0430 # &gt;&gt; RuntimeError: \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0438 \u0448\u0430\u0433\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u0442\u0435\u043d\u0437\u043e\u0440\u0430  # \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c .reshape()<\/code><\/pre>\n<p> \u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u0435\u0442 \u043e \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0438 \u0448\u0430\u0433\u043e\u043c \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043d\u0437\u043e\u0440\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0435\u043d\u0437\u043e\u0440 \u0431\u044b\u043b \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d. \u042d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043d\u0437\u043e\u0440\u0430, \u043d\u0435 \u043c\u0435\u043d\u044f\u044f \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0432 \u043d\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 <code>.view()<\/code> \u0438 <code>.reshape().<\/code> <code>.view()<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <code>.reshape()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043f\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u044b \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b. <\/p>\n<p> \u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043c \u043a \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430: \u0444\u043e\u0440\u043c\u0430 \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0432 \u043d\u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"python\">struct Tensor { data: torch.Storage. grad: Tensor, grad_fn: BackwardFn shape: Array \/\/ \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442 stride: Array .... \/\/ \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 }<\/code><\/pre>\n<p> <\/p>\n<h3>\u0428\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u0435<\/h3>\n<p> \u041e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0437\u043e\u043d, \u0433\u0434\u0435 \u0432 PyTorch \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0431\u0430\u0433\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u044f. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u044f \u0432 PyTorch: <\/p>\n<ol>\n<li>\u041e\u0431\u0430 \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e 1 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044e<\/li>\n<li>\u0412\u0441\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u0430\u0432\u044b\u0445, \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u043f\u0440\u0438\u0447\u0451\u043c, \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e 1, \u043b\u0438\u0431\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u0443\u0442\u0430\u043d\u044b\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0449\u0435 \u0441\u0440\u0430\u0437\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u0444\u043e\u0440\u043c\u0430. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0442\u0430\u043a: <\/li>\n<\/ol>\n<p> <\/p>\n<pre><code class=\"python\">for each dimension, starting from the right: if both shapes have this dimension: if they are different: neither is 1: error else: use larger dimension  else they are the same: use dimension else: use whichever dimension exists<\/code><\/pre>\n<p> \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043e\u0431\u0441\u0442\u043e\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u043d\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0430 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043e\u043e\u0431\u0449\u0438\u043c \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u0442\u043e\u0447\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0442\u0435\u043d\u0437\u043e\u0440\u0430, \u0442\u0430\u043a \u0438 \u0444\u043e\u0440\u043c\u0443, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0443\u044e \u0432 \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 (\u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e). \u041a\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u043d\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0432\u0430 \u043d\u0430\u043b\u0435\u0432\u043e, \u043d\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c\u0441\u044f <code>actual_shape[i] != broadcasted_shape[i]<\/code>, \u0438 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u0422\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c 0-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0434\u043e\u043b\u044c \u044d\u0442\u043e\u0433\u043e i-\u0433\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f.<\/p>\n<p> \u041f\u0440\u043e\u0434\u0443\u043c\u0430\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0435\u043d\u0437\u043e\u0440 <code>a<\/code> \u0444\u043e\u0440\u043c\u044b 1 x 2, \u0438 \u043c\u044b \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0441 \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u043c <code>b<\/code> \u0444\u043e\u0440\u043c\u044b 2 x 2. \u0418\u0437 \u043f\u0440\u0430\u0432\u0438\u043b \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u044f \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438 \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u043d\u0437\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0444\u043e\u0440\u043c\u0443 2 x 2. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. <\/p>\n<pre><code class=\"python\">a = torch.tensor([1, 2]).reshape(1, 2) # 1 x 2 b = torch.tensor([[3, 4], [5, 6]]) # 2 x 2 c = torch.zeros((2, 2)) # \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e a + b \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0442\u0435\u043d\u0437\u043e\u0440 2x2   # \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c: \u043f\u0435\u0440\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0432\u0430  c[0][0] = a[0][0] + b[0][0] c[0][1] = a[0][1] + b[0][1]  # \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c: \u0432\u0442\u043e\u0440\u043e\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0432\u0430  # \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u043e\u043d\u043e \u0431\u044b\u043b\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0432 2x2 \u0432\u0434\u043e\u043b\u044c \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f # \u0443\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e broadcasted_shape[1] = 2 \u0447\u0442\u043e \u043d\u0435 \u0440\u0430\u0432\u043d\u043e   # \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 shape[1] = 1, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e # \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u043b\u0438 0-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0434\u043e\u043b\u044c \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f c[1][0] = a[0][0] + b[1][0]  c[1][1] = a[0][1] + b[1][1]  assert torch.equal(a + b, c) # true <\/code><\/pre>\n<p> \u041b\u0430\u0434\u043d\u043e, \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0435\u0440\u0435\u0443\u0441\u043b\u043e\u0436\u043d\u0451\u043d\u043d\u044b\u043c, \u0438 \u0432\u044b \u0443\u0436\u0435 \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u0435 \u0441 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u0438, \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u0434\u0432\u0443\u043c\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b.<\/p>\n<p> \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043a\u043b\u043e\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u0437\u0434\u0435\u0440\u0436\u0435\u043a \u043d\u0438 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043d\u0438 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u0435\u0441\u043b\u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0442\u0435\u043d\u0437\u043e\u0440 \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443.<\/p>\n<p> \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u043c\u0435\u043d\u044c\u0448\u0435\u043c \u0442\u0435\u043d\u0437\u043e\u0440\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u0442 \u0436\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u043d\u044c\u0448\u0435\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0438. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u0435.<\/p>\n<h3>\u0428\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u0430\u0442\u0440\u0438\u0446<\/h3>\n<p> \u0412\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0442\u044c 2 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u041d\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u043b\u044e\u0431\u043e\u0439 \u043e\u0431\u0449\u0435\u0439 n-\u043c\u0435\u0440\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b? \u0412 PyTorch \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 <a href=\"https:\/\/pytorch.org\/docs\/stable\/generated\/torch.matmul.html\">\u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d<\/a>, \u0438 \u044f \u0432\u0441\u0435\u043c \u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u044b\u0448\u0435. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e n-\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u044f \u0440\u0435\u0437\u044e\u043c\u0438\u0440\u043e\u0432\u0430\u043b \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0433\u043e \u043d\u0438\u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: <\/p>\n<ol>\n<li>\u0411\u0435\u0440\u0451\u043c 2 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0438\u0445 \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0442\u044c. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430. <\/li>\n<li>\u0428\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f. \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u043e\u0439 \u0442\u0430\u043a: [\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e] + [\u0444\u043e\u0440\u043c\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446]<\/li>\n<li>3\u0421\u0447\u0438\u0442\u0430\u0435\u043c [\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e] \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435\u043c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 and perform batched matrix multiplication.<\/li>\n<\/ol>\n<p> \u0421\u043d\u043e\u0432\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<pre><code class=\"python\">a = torch.randn((3, 4, 1, 2)) # 3 x 4 x 1 x 2 b = torch.randn((1, 2, 3)) # 1 x 2 x 3  # \u0424\u043e\u0440\u043c\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u0430\u0442\u0440\u0438\u0446: 1x2 @ 2x3 -&gt; 1x3 # \u041f\u0430\u043a\u0435\u0442\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430: \u043c\u044b \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c (3, 4) \u0438 (1) -&gt; (3, 4) # \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u0444\u043e\u0440\u043c\u0430: 3 x 4 x 1 x 3 c = torch.zeros((3, 4, 1, 3)) # \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f (3, 4) for i in range(3): for j in range(4): a_slice = a[i][j] # 1 x 2 b_slice = b[0] # 2 x 3 c[i][j] = a_slice @ b_slice # 1 x 3  assert torch.equal(torch.matmul(a, b), c)<\/code><\/pre>\n<p> \u0427\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0442\u0435\u043d\u0437\u043e\u0440\u044b \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439. \u041d\u043e \u044f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u043f\u0430\u043a\u0435\u0442\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443, \u0442\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0435\u0435, \u0447\u0435\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u0435\u043d PyTorch. \u0421\u0430\u043c\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0432\u0430\u0441 \u043d\u0435 \u0442\u0430\u043a\u0438\u043c \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043f\u043e\u043a\u0430 \u0432\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 PyTorch.<\/p>\n<h3>\u041e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435<\/h3>\n<p> <\/p>\n<blockquote><p>\u041f\u0435\u0440\u0435\u0434 \u0447\u0442\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u0430\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0432\u044b \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/www.youtube.com\/watch?v=VMj-3S1tku0\">\u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e<\/a> \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u043e\u0442 \u0410\u043d\u0434\u0440\u0435\u044f \u041a\u0430\u0440\u043f\u0430\u0442\u043e\u0433\u043e.<\/p><\/blockquote>\n<p> \u0421\u0443\u0442\u044c PyTorch \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u0430 \u0432 \u0435\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0435 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u0446\u0435\u043b\u043e\u043c, \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u0435\u043d\u0437\u043e\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, PyTorch \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0441\u0442\u0440\u043e\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0435\u0441\u044c \u0435\u0451 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444. \u0417\u0430\u0442\u0435\u043c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>.backward()<\/code>. \u042d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u043a\u0440\u0443\u043f\u043d\u0430\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0432 PyTorch. \u0427\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>.backward()<\/code> \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u0442\u0435\u043a\u0443\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 \u043d\u0430\u0443\u0447\u0443 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0438 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<blockquote><p>\u042d\u0442\u0438 94 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 [\u0432 micrograd] \u2014 \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u0412\u0441\u0451 \u043f\u0440\u043e\u0447\u0435\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u043b\u0438\u0448\u044c \u0441 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438.<br \/> <a href=\"https:\/\/x.com\/karpathy\/status\/1803963383018066272\">\u0410\u043d\u0434\u0440\u0435\u0439 \u041a\u0430\u0440\u043f\u0430\u0442\u044b\u0439<\/a><\/p><\/blockquote>\n<p> \u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439 \u0443\u043c\u0435\u044e\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u043c\u0438 \u0438 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Chain_rule\">\u0446\u0435\u043f\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c<\/a> \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e \u0441\u043a\u0430\u043b\u044f\u0440\u0430\u043c\u0438. \u041d\u043e \u043d\u0435 \u0442\u0430\u043a \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0442\u0435\u043d\u0437\u043e\u0440\u0430\u043c\u0438 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p> \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 <code>r-nn<\/code> \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u2014 \u0438 \u043e\u043d\u0438 \u043e\u0431\u043e\u0431\u0449\u0430\u044e\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u0432 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0438 \u0432 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435. \u0414\u0430\u043b\u0435\u0435 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u043d\u0437\u043e\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043d\u0445\u043e\u0440\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0438 \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p> \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f +, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u2217, \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c xk, \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f ex \u0438 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430 ln(). 5 \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u0432 \u044d\u0442\u043e\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 softmax, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0439.<\/p>\n<p> <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zk\/vj\/7u\/zkvj7uf7vqsjandc6ulaywu_kxu.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/zk\/vj\/7u\/zkvj7uf7vqsjandc6ulaywu_kxu.png\"\/><\/p>\n<p> \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0430\u044f \u043e\u0442 ex \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e ex. \u0412 \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c x(-1).<\/p>\n<p> \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043d\u0430\u0448\u0443 <code>r-nn<\/code>, \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0448\u0430\u0433\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0438\u0437 \u0447\u0435\u0433\u043e \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0430\u044f \u043e\u0442 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043c\u0430\u0442\u0440\u0438\u0446 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. \u042d\u0442\u043e \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u044f\u0442\u044c, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 \u043a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0434 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041d\u043e \u044f \u0432\u0438\u0436\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u043a\u0440\u0430\u0441\u043e\u0442\u0443 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0444\u0430\u043a\u0442\u0435, \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u0438 \u043b\u0435\u0433\u0447\u0435 \u0443\u0441\u0432\u043e\u0438\u0442\u044c \u0441\u0443\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p> \u0420\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u044f \u043e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430\u0445 \u0441 \u0442\u0430\u043a\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u00ab\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439\u00bb \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435 \u0443\u0441\u0432\u043e\u0438\u0442\u044c, \u043a\u0430\u043a \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0434 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u0430\u043a <code>.reshape()<\/code>, <code>.transpose()<\/code>, <code>.cat<\/code> \u0438 <code>.split()<\/code> \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0435 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0438 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0438 \u043d\u0430 \u0435\u0433\u043e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442. \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u043c \u0432\u043e\u0437\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0430\u043c\u0438 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>.reshape(-1)<\/code>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u044d\u0444\u0444\u0435\u043a\u0442, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u044b\u0437\u0432\u0430\u043b\u0438 <code>.reshape(-1)<\/code> \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0443 \u0442\u0435\u043d\u0437\u043e\u0440\u0430. <\/p>\n<h3>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<p> \u041f\u0440\u043e\u0435\u043a\u0442 <code>r-nn<\/code> \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0433\u043e\u0442\u043e\u0432\u044f \u0435\u0433\u043e, \u044f \u0441\u0442\u0440\u0435\u043c\u0438\u043b\u0441\u044f \u043a \u044f\u0441\u043d\u043e\u0441\u0442\u0438, \u0430 \u043d\u0435 \u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0440\u0430\u0437\u0434\u0435\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u044b\u043b\u0438 \u0431\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<h3>\u041f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446<\/h3>\n<p> \u041f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 \u043f\u043e\u0432\u0441\u044e\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445 (\u0438 \u0432 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u043e\u0431\u0449\u0435), \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0431\u0438\u0437\u043d\u0435\u0441 \u043d\u0430 \u0442\u0440\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u0434\u043e\u043b\u043b\u0430\u0440\u043e\u0432. \u042f \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u043c\u044b\u0435 \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 GPU.<\/p>\n<p> \u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u043e\u043f\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0441\u0430\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u043c. \u041d\u0430\u043f\u043e\u043c\u043d\u044e: \u0438\u043c\u0435\u044f <code>A @ B<\/code>, \u043c\u044b \u0440\u0430\u0437 \u0437\u0430 \u0440\u0430\u0437\u043e\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u044f\u0434\u0430 \u0432 <code>A<\/code> \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0432 <code>B<\/code>. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0432 PyTorch \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u0434\u043e\u043b\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041f\u0440\u0438\u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0432 A, \u043c\u044b \u043d\u0435 \u0434\u043e\u0431\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u044d\u0448\u0430 \u0432 B. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043b\u0430\u0441\u044c \u0432\u0434\u043e\u043b\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 <code>B<\/code> \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e, <a href=\"https:\/\/www.nic.uoregon.edu\/~khuck\/ts\/acumem-report\/manual_html\/ch03s02.html#:~:text=When%20the%20processor%20accesses%20a,called%20the%20cache%20line%20size.\">\u043d\u0435 \u043c\u0435\u043d\u044f\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u044d\u0448-\u043b\u0438\u043d\u0438\u044e<\/a>. \u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e <code>O(N)<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0451 \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441 <code>r-nn<\/code> \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/github.com\/nreHieW\/r-nn\/blob\/main\/src\/core\/tensor\/matmul.rs#L35\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p> \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0432\u0441\u0435\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u0440\u0430\u0437\u0443, \u0430 \u043b\u0438\u0448\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0435\u0451 \u0431\u043b\u043e\u043a\u0430\u043c\u0438. \u0422\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u0447\u043d\u043e\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435. \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043d\u0430 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043b\u043a\u0438\u0435 \u0431\u043b\u043e\u043a\u0438, \u0438 \u0443\u0436\u0435 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u043c\u0430\u0445\u043e\u0432 \u043a\u044d\u0448\u0430, \u0442\u043e\u0436\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u0435\u043b\u043a\u0438\u043c\u0438 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<p> \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0432\u0441\u0435\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u0440\u0430\u0437\u0443, \u0430 \u043b\u0438\u0448\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0435\u0451 \u0431\u043b\u043e\u043a\u0430\u043c\u0438. \u0422\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Block_matrix\">\u0431\u043b\u043e\u0447\u043d\u043e\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/a>. \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043d\u0430 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043b\u043a\u0438\u0435 \u0431\u043b\u043e\u043a\u0438, \u0438 \u0443\u0436\u0435 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u043c\u0430\u0445\u043e\u0432 \u043a\u044d\u0448\u0430, \u0442\u043e\u0436\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u0435\u043b\u043a\u0438\u043c\u0438 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<h3>\u041f\u0430\u043c\u044f\u0442\u044c \u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438<\/h3>\n<p> \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (a+b)\u2217(c+d)=e. \u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c Python \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">_t1 = a + b _t2 = c + d e = _t1 + _t2<\/code><\/pre>\n<p> \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>e.backward()<\/code> \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>_t1<\/code> \u0438 <code>_t2<\/code> \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <code>a, b, c<\/code> \u0438 <code>d<\/code>. \u0412 \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 autograd \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f _t1 \u0438 _t2, \u0430 \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0445 \u044d\u0442\u043e \u0432\u043b\u0435\u0447\u0451\u0442 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u0435 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ls\/n1\/jj\/lsn1jj-5fljeuysbsvx-bpmanjy.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/ls\/n1\/jj\/lsn1jj-5fljeuysbsvx-bpmanjy.png\"\/>, \u0438 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e <code>_t1<\/code> \u0438 <code>_t2<\/code> \u043d\u0430\u043c \u0434\u0430\u043b\u0435\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 PyTorch \u0434\u0430\u043b\u0435\u0435 <a href=\"https:\/\/pytorch.org\/docs\/stable\/checkpoint.html\">\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/a>. <\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e<\/h3>\n<p> \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0441\u043c\u043e\u0433 \u0432\u0430\u0441 \u0443\u0431\u0435\u0434\u0438\u0442\u044c: \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0448\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043d\u0443\u043b\u044f, \u044d\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u0447\u0451\u043c, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0432 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u043a \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0443\u0441\u0432\u043e\u0435\u043d\u0438\u044e \u0442\u0435\u043c\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u043e\u0442 \u0441\u0430\u043c\u044b\u0445 \u0430\u0437\u043e\u0432. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u0432\u044b \u0441\u0442\u0430\u043b\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u0435\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e PyTorch \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>.backward()<\/code>, \u043e\u043d\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0432\u0430\u0441 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u043c. <\/p>\n<p> \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043b\u044f <code>r-nn<\/code> \u0432\u044b\u043b\u043e\u0436\u0435\u043d <a href=\"https:\/\/github.com\/nreHieW\/r-nn\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/872796\/\"> https:\/\/habr.com\/ru\/articles\/872796\/<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u044f \u0437\u0430\u0434\u0430\u043b \u0441\u0435\u0431\u0435 \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c micrograd \u043d\u0430 Rust, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u0417\u0430\u043d\u0438\u043c\u0430\u044f\u0441\u044c \u044d\u0442\u0438\u043c, \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0431\u0430\u0437\u0435 micrograd \u043f\u043e\u043b\u043d\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u0432. \u042f \u0437\u043d\u0430\u043a\u043e\u043c \u0441 PyTorch \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0430\u0433\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043c\u043d\u0435 \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u043e \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043d\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 Python, \u044d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0432\u0438\u0434\u0435\u043b\u0430\u0441\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. <\/p>\n<p> \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u0432\u043e\u0438\u043b \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u043d \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b \u043c\u0435\u043d\u044f \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e PyTorch \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0443 PyTorch. \u0412\u043e\u0437\u044c\u043c\u0443\u0441\u044c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e, \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044f \u044d\u0442\u0438\u0445 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u0438\u0445 \u0437\u0430 \u0447\u0438\u0441\u0442\u0443\u044e \u043c\u043e\u043d\u0435\u0442\u0443, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043d\u0435\u0441\u0442\u0438 \u0432 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0446\u0435\u043b\u0443\u044e \u043a\u0443\u0447\u0443 \u0431\u0430\u0433\u043e\u0432. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d, \u0430 \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u0441\u044f \u0432\u0430\u0448 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0438\u0447\u0435\u043c\u0443 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-444716","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444716","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=444716"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444716\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=444716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=444716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=444716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}