{"id":306607,"date":"2020-07-08T09:00:22","date_gmt":"2020-07-08T09:00:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=306607"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-07-08T09:00:22","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=306607","title":{"rendered":"\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 RoI Pooling \u0432 TensorFlow + Keras"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/510094\/\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/medium.com\/xplore-ai\/implementing-attention-in-tensorflow-keras-using-roi-pooling-992508b6592b\">&quot;Implementing RoI Pooling in TensorFlow + Keras&quot;<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Jaime Sevilla.<\/p>\n<p>  <\/p>\n<p><em>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043f\u0440\u043e\u0445\u043e\u0436\u0443 \u043a\u0443\u0440\u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0412 \u0443\u0447\u0435\u0431\u043d\u043e\u043c \u0431\u043b\u043e\u043a\u0435 &quot;\u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0435 \u0437\u0440\u0435\u043d\u0438\u0435&quot; \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 RoI Pooling \u0441\u043b\u043e\u0451\u0432. \u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u043d\u0438\u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u044f \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c.<\/em><\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u0438 \u043e\u0431\u0449\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 RoI pooling (<strong>Region of Interest<\/strong> \u2014 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432) \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0435\u0432 Keras \u0441\u0440\u0435\u0434\u044b TensorFlow.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0426\u0435\u043b\u0435\u0432\u0430\u044f \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u2014 \u043b\u044e\u0434\u0438, \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0442\u0435\u043e\u0440\u0438\u0435\u0439 (\u0441\u0432\u0435\u0440\u0442\u043e\u0447\u043d\u044b\u0445) \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 (CNN) \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/keras.io\/#getting-started-30-seconds-to-keras\">Keras<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0434\u0435\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u0434\u0430, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044c <a href=\"https:\/\/gist.github.com\/Jsevillamol\/0daac5a6001843942f91f2a3daea27a7\">\u0441\u044e\u0434\u0430<\/a> \u0438 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043b\u0430\u0439\u043a \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0442\u044c\u0435\u0439!<\/p>\n<p>  <\/p>\n<h1 id=\"ponimanie-roi-pooling\">\u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 RoI Pooling<\/h1>\n<p>  <\/p>\n<p><strong>RoI Pooling<\/strong> \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d \u0420\u043e\u0441\u0441\u043e\u043c \u0413\u0438\u0440\u0448\u0438\u043a\u043e\u043c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/arxiv.org\/abs\/1504.08083\">Fast R-CNN<\/a> \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0435\u0433\u043e \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f <strong>RoI Pooling<\/strong> \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 (<strong>RoI<\/strong> \u2014 regions of interest), \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0440\u0430\u043c\u043a\u0438. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0438 (embedding (\u0432\u043b\u043e\u0436\u0435\u043d\u0438\u044f) \u2014 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 (\u043a\u0443\u0441\u043e\u0447\u043a\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438) \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u0443) \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e RoI.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 R-CNN \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432-\u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0440\u0430\u043c\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u043e\u0447\u043a\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/700\/1*A2IfHwmF8MT_kmwE4DmnDA.jpeg\" alt=\"\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432-\u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430, \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u0444\u043e\u0440\u043c\u0443!<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u043e\u0447\u043a\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0430 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u041a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e?<\/p>\n<p>  <\/p>\n<p>\u0412 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f (pooling).<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <strong>max pooling<\/strong>, \u0433\u0434\u0435 \u043c\u044b \u0434\u0435\u043b\u0438\u043c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 (\u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f) \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0445\u043e\u0434, \u0431\u0435\u0440\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/700\/1*krZsn7QzWQ9Oux6MraFjAw.jpeg\" alt=\"\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f maxpool \u0434\u0435\u043b\u0438\u0442 \u043a\u0430\u0436\u0434\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043d\u0430 \u043f\u0443\u043b\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430\"\/><\/p>\n<p>  <\/p>\n<blockquote><p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f maxpool \u0434\u0435\u043b\u0438\u0442 \u043a\u0430\u0436\u0434\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043d\u0430 \u043f\u0443\u043b\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430<\/p><\/blockquote>\n<p>\u042d\u0442\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u2013 \u043a\u0443\u0441\u043e\u0447\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u0431\u043b\u043e\u043a\u0430\u043c\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438: \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0442 \u043d\u0430 \u0438\u0434\u0435\u044e. \u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0443\u044e RoI \u043d\u0430 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0438 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445?<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/700\/1*IPoKQl9x7qcAOwX2Q0UJLg.jpeg\" alt=\"\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f ROI Pooling \u0434\u0435\u043b\u0438\u0442 \u0441\u0435\u0442\u043a\u043e\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0441\u0435  \u0447\u0430\u0441\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u043c\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 pooling.\"\/><\/p>\n<p>  <\/p>\n<blockquote><p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f ROI Pooling \u0434\u0435\u043b\u0438\u0442 \u0441\u0435\u0442\u043a\u043e\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0441\u0435 \u0447\u0430\u0441\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u043c\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 pooling.<\/p><\/blockquote>\n<p>\u0418 \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u043e\u0439 ROI Pooling.<\/p>\n<p>  <\/p>\n<h1 id=\"oblasti-primeneniya-roi-pooling\">\u041e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f RoI Pooling.<\/h1>\n<p>  <\/p>\n<p><strong>RoI Pooling<\/strong> \u2014 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u043d \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0432\u0435\u0442 \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 RoI, \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u044f \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0438 \u0438\u0445 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0430\u043c\u0438. \u041c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0434\u0432\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0435\u0433\u043e \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b.<br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e RoI Pooling \u0431\u044b\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d), \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 (\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432), \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043a\u0432\u043e\u0437\u043d\u0443\u044e (end-to-end) \u043e\u0434\u043d\u043e\u043f\u0440\u043e\u0445\u043e\u0434\u043d\u0443\u044e (single-pass) \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/700\/1*Zw4YAo0OVFQdU_Fux-03-Q.png\" alt=\"Fast R-CNN, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0430\u044f RoI Pooling, \u0420\u043e\u0441\u0441 \u0413\u0438\u0440\u0448\u0438\u043a\"\/><\/p>\n<p>  <\/p>\n<blockquote><p><a href=\"https:\/\/arxiv.org\/abs\/1504.08083\">Fast R-CNN<\/a>, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0430\u044f RoI Pooling, \u0420\u043e\u0441\u0441 \u0413\u0438\u0440\u0448\u0438\u043a<\/p><\/blockquote>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 R-CNN \u0443 \u043d\u0430\u0441 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 (RoI). RoI Pooling \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 CNN \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0435\u0433\u0438\u043e\u043d \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<br \/>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432-\u043a\u0430\u0434\u0438\u0434\u0430\u0442\u043e\u0432, RoI Pooling \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f (<strong>visual attention<\/strong>).<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/700\/1*Rtz-VF_G9TK47upKOjSJSQ.png\" alt=\"Attentional Network \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u0435\u0442\u0435\u043a\u0446\u0438\u0438  \u043e\u0431\u044c\u0435\u043a\u0442\u043e\u0432 , \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0430\u044f ROI Pooling, \u0430\u0432\u0442\u043e\u0440\u044b Hara \u0438 \u0434\u0440..\"\/><\/p>\n<p>  <\/p>\n<blockquote><p><a href=\"https:\/\/arxiv.org\/pdf\/1702.01478.pdf\">Attentional Network \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u0435\u0442\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u044c\u0435\u043a\u0442\u043e\u0432<\/a>, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0430\u044f ROI Pooling, \u0430\u0432\u0442\u043e\u0440\u044b Hara \u0438 \u0434\u0440..<\/p><\/blockquote>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432 <a href=\"https:\/\/arxiv.org\/pdf\/1702.01478.pdf\">Attentional Network \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u0435\u0442\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u044c\u0435\u043a\u0442\u043e\u0432<\/a> \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a Hara \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u0430\u0432\u0442\u043e\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c <strong>attention<\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 ROI \u0438 ROI Pooling. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430 (t = 1), \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e ROI Pooling \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u0442 \u043a \u043f\u043e\u043b\u043d\u043e\u0441\u0432\u044f\u0437\u043d\u044b\u043c \u0441\u043b\u043e\u044f\u043c (Fully Connected). \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 Glimpse (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435) (t = 2) \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u0442\u0441\u044f \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ROI Pooling. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0422 \u0440\u0430\u0437.<\/p>\n<p>  <\/p>\n<h1 id=\"realizaciya\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/h1>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043c\u0438\u043d\u0443\u0442\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0442\u0438\u043f\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0441\u043b\u043e\u044f ROI.<\/p>\n<p>  <\/p>\n<p>\u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0442\u0435\u043d\u0437\u043e\u0440\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0430\u043a\u0435\u0442 (batch) \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0427\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435, \u0432\u0441\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \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. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 (batch_size, img_width, img_height, n_channels), \u0433\u0434\u0435 batch_size- \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, img_width \u2014 \u0448\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, img_height \u2014 \u0432\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, n_channels \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438.<\/li>\n<li>\u041f\u0430\u043a\u0435\u0442 (batch) \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 ROI. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u0442\u0435\u043d\u0437\u043e\u0440, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439-\u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d \u0441 4 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438, \u0444\u043e\u0440\u043c\u0430 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 (batch_size, n_rois, 4), \u0433\u0434\u0435 batch_size \u2014 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u0430 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 ROI, n_rois \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 ROI.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0421\u043f\u0438\u0441\u043e\u043a \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043a\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043d\u044b\u0445 \u043a\u0430\u0436\u0434\u043e\u0439 ROI. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c (batch_size, n_rois, pooled_width, pooled_height, n_channels). batch_size- \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, n_rois \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 ROI, pooled_width \u2014 \u0448\u0438\u0440\u0438\u043d\u0430 \u043e\u0431\u044c\u0435\u0434\u0438\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, pooled_height\u2014 \u0432\u044b\u0441\u043e\u0442\u0430 \u043e\u0431\u044c\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, n_channels \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<h1 id=\"kod-v-keras\">\u041a\u043e\u0434 \u0432 Keras<\/h1>\n<p>  <\/p>\n<p>Keras \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u043b\u043e\u0438 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Layer.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/www.tensorflow.org\/api_docs\/python\/tf\/keras\/layers\/Layer\">tf.keras<\/a> \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <strong>init<\/strong>, build \u0438 call \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0446\u0435\u043b\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 build \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0441\u043e\u0432 \u0441\u043b\u043e\u044f, \u0430 \u043d\u0430\u0448 \u0441\u043b\u043e\u0439 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u0435\u0441\u043e\u0432, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 compute_output_shape.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u0432\u0441\u0435 \u043a\u0443\u0441\u043a\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def __init__(self, pooled_height, pooled_width, **kwargs):     self.pooled_height = pooled_height     self.pooled_width = pooled_width     super(ROIPoolingLayer, self).__init__(**kwargs)<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440<\/em> \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0432\u044b\u0441\u043e\u0442\u0443 \u0438 \u0448\u0438\u0440\u0438\u043d\u0443 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def compute_output_shape(self, input_shape):     &quot;&quot;&quot; Returns the shape of the ROI Layer output     &quot;&quot;&quot;     feature_map_shape, rois_shape = input_shape     assert feature_map_shape[0] == rois_shape[0]     batch_size = feature_map_shape[0]     n_rois = rois_shape[1]     n_channels = feature_map_shape[3]     return (batch_size, n_rois, self.pooled_height,              self.pooled_width, n_channels)<\/code><\/pre>\n<p>  <\/p>\n<p><em>compute_output_shape<\/em> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043a\u0430\u0436\u0435\u0442 \u043d\u0430\u043c, \u043a\u0430\u043a\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0445\u043e\u0434 \u0441\u043b\u043e\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 (<em>call<\/em>). \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u2014 \u044d\u0442\u043e \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0436\u0438\u0432\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043b\u043e\u044f. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0432\u0430 \u0442\u0435\u043d\u0437\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u043b\u043e\u044f ROI Pooling, \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0435\u043d\u0437\u043e\u0440 \u0441 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u0434\u043d\u0443 ROI \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">@staticmethod def _pool_roi(feature_map, roi, pooled_height, pooled_width):   &quot;&quot;&quot; Applies ROI Pooling to a single image and a single ROI   &quot;&quot;&quot;# Compute the region of interest           feature_map_height = int(feature_map.shape[0])   feature_map_width  = int(feature_map.shape[1])    h_start = tf.cast(feature_map_height * roi[0], 'int32')   w_start = tf.cast(feature_map_width  * roi[1], 'int32')   h_end   = tf.cast(feature_map_height * roi[2], 'int32')   w_end   = tf.cast(feature_map_width  * roi[3], 'int32')    region = feature_map[h_start:h_end, w_start:w_end, :] ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u0448\u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442, \u0433\u0434\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u0430\u0436\u0434\u043e\u0439 ROI \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430\u0445, \u043a\u0430\u043a \u0447\u0438\u0441\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 0 \u0438 1. \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e, \u043a\u0430\u0436\u0434\u0430\u044f ROI \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f 4-\u043c\u0435\u0440\u043d\u044b\u043c \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u043c, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c \u0447\u0435\u0442\u044b\u0440\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b (<em>x_min, y_min, x_max, y_max <\/em>).<br \/>  \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u0430\u0436\u0434\u043e\u0439 ROI \u0432 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u043d\u043e \u044d\u0442\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0445\u0443\u0436\u0435: \u043e\u0431\u0449\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u0440\u0438\u043d\u0442 \u0441 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u043d\u0438\u043c\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0432\u0435\u0440\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u043b\u043e\u0439 ROI Pooling, \u0447\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442 \u043d\u0430\u0441 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0440\u0430\u043c\u043a\u0438 ROI.<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0434\u044c\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u044b\u0445 \u0441\u0440\u0435\u0437\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c TensorFlow.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">... # Divide the region into non overlapping areas region_height = h_end - h_start region_width  = w_end - w_start h_step = tf.cast(region_height \/ pooled_height, 'int32') w_step = tf.cast(region_width  \/ pooled_width , 'int32')  areas = [[(            i*h_step,             j*w_step,             (i+1)*h_step if i+1 &lt; pooled_height else region_height,             (j+1)*w_step if j+1 &lt; pooled_width else region_width           )            for j in range(pooled_width)]           for i in range(pooled_height)] ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432 ROI, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c 2D \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u0432, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432\u0437\u044f\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c.<\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0435\u0442\u043a\u0443 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0441\u0435\u043a\u0442\u043e\u0440\u0430, \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c ROI \u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c\u0438 (<em>region_height \/\/ pooled_height, region_width \/\/ pooled_width<\/em>), \u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 ROI, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043d\u0438 \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 2D \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u043c\u043e\u043a, \u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">... # Take the maximum of each area and stack the result def pool_area(x):    return tf.math.reduce_max(region[x[0]:x[2],x[1]:x[3],:], axis=[0,1])  pooled_features = tf.stack([[pool_area(x) for x in row] for row in areas]) return pooled_features<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u044b\u0448\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0432\u0441\u044e \u043c\u0430\u0433\u0438\u044e. \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <em>pool_area<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0443\u044e \u0440\u0430\u043c\u043a\u0443, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u043c\u0438, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u0442\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b\u0438, \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<br \/>  \u041c\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c <em>pool_area<\/em> \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f list comprehension .<\/p>\n<p>  <\/p>\n<p>\u041a \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0442\u0435\u043d\u0437\u043e\u0440 \u0444\u043e\u0440\u043c\u044b (<em>pooled_height, pooled_width, n_channels<\/em>), \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0443\u043b\u043b\u0438\u043d\u0433\u0430 \u043e\u0434\u043d\u043e\u0439 RoI \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433 \u2014 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 RoI \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438. \u042d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 <em>tf.map_fn<\/em> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043d\u0437\u043e\u0440\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c\u0438 (<em>n_rois, pooled_height, pooled_width, n_channels<\/em>).<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">@staticmethod def _pool_rois(feature_map, rois, pooled_height, pooled_width):   &quot;&quot;&quot; Applies ROI pooling for a single image and varios ROIs   &quot;&quot;&quot;   def curried_pool_roi(roi):      return ROIPoolingLayer._pool_roi(feature_map, roi,                                       pooled_height, pooled_width)    pooled_areas = tf.map_fn(curried_pool_roi, rois, dtype=tf.float32)   return pooled_areas<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0431\u0430\u0442\u0447\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 <em>tf.map_fn<\/em> \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0448 \u0432\u0432\u043e\u0434 x), \u0442\u043e \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u043b\u0438\u0441\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043c \u0437\u0438\u043f\u0430\u043d\u0443\u043b\u0438 \u0431\u0430\u0442\u0447.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def call(self, x):   &quot;&quot;&quot; Maps the input tensor of the ROI layer to its output   &quot;&quot;&quot;   def curried_pool_rois(x):      return ROIPoolingLayer._pool_rois(x[0], x[1],                                        self.pooled_height,                                        self.pooled_width)    pooled_areas = tf.map_fn(curried_pool_rois, x, dtype=tf.float32)   return pooled_areas<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>dtype<\/em> \u0434\u043b\u044f <em>tf.map_fn<\/em> \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0438\u043f\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0433\u043e \u0432\u0432\u043e\u0434\u0430. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0447\u0430\u0449\u0435, \u0447\u0442\u043e\u0431\u044b \u0447\u0435\u0442\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0442\u0438\u043f\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u0433\u0440\u0430\u0444\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 Tensorflow.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043b\u043e\u0436\u0438\u043c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import tensorflow as tf from tensorflow.keras.layers import Layer  class ROIPoolingLayer(Layer):     &quot;&quot;&quot; Implements Region Of Interest Max Pooling          for channel-first images and relative bounding box coordinates          # Constructor parameters             pooled_height, pooled_width (int) --                specify height and width of layer outputs          Shape of inputs             [(batch_size, pooled_height, pooled_width, n_channels),              (batch_size, num_rois, 4)]          Shape of output             (batch_size, num_rois, pooled_height, pooled_width, n_channels)      &quot;&quot;&quot;     def __init__(self, pooled_height, pooled_width, **kwargs):         self.pooled_height = pooled_height         self.pooled_width = pooled_width          super(ROIPoolingLayer, self).__init__(**kwargs)      def compute_output_shape(self, input_shape):         &quot;&quot;&quot; Returns the shape of the ROI Layer output         &quot;&quot;&quot;         feature_map_shape, rois_shape = input_shape         assert feature_map_shape[0] == rois_shape[0]         batch_size = feature_map_shape[0]         n_rois = rois_shape[1]         n_channels = feature_map_shape[3]         return (batch_size, n_rois, self.pooled_height,                  self.pooled_width, n_channels)      def call(self, x):         &quot;&quot;&quot; Maps the input tensor of the ROI layer to its output              # Parameters                 x[0] -- Convolutional feature map tensor,                         shape (batch_size, pooled_height, pooled_width, n_channels)                 x[1] -- Tensor of region of interests from candidate bounding boxes,                         shape (batch_size, num_rois, 4)                         Each region of interest is defined by four relative                          coordinates (x_min, y_min, x_max, y_max) between 0 and 1             # Output                 pooled_areas -- Tensor with the pooled region of interest, shape                     (batch_size, num_rois, pooled_height, pooled_width, n_channels)         &quot;&quot;&quot;         def curried_pool_rois(x):            return ROIPoolingLayer._pool_rois(x[0], x[1],                                              self.pooled_height,                                              self.pooled_width)          pooled_areas = tf.map_fn(curried_pool_rois, x, dtype=tf.float32)          return pooled_areas      @staticmethod     def _pool_rois(feature_map, rois, pooled_height, pooled_width):         &quot;&quot;&quot; Applies ROI pooling for a single image and varios ROIs         &quot;&quot;&quot;         def curried_pool_roi(roi):            return ROIPoolingLayer._pool_roi(feature_map, roi,                                             pooled_height, pooled_width)          pooled_areas = tf.map_fn(curried_pool_roi, rois, dtype=tf.float32)         return pooled_areas      @staticmethod     def _pool_roi(feature_map, roi, pooled_height, pooled_width):         &quot;&quot;&quot; Applies ROI pooling to a single image and a single region of interest         &quot;&quot;&quot;          # Compute the region of interest                 feature_map_height = int(feature_map.shape[0])         feature_map_width  = int(feature_map.shape[1])          h_start = tf.cast(feature_map_height * roi[0], 'int32')         w_start = tf.cast(feature_map_width  * roi[1], 'int32')         h_end   = tf.cast(feature_map_height * roi[2], 'int32')         w_end   = tf.cast(feature_map_width  * roi[3], 'int32')          region = feature_map[h_start:h_end, w_start:w_end, :]          # Divide the region into non overlapping areas         region_height = h_end - h_start         region_width  = w_end - w_start         h_step = tf.cast( region_height \/ pooled_height, 'int32')         w_step = tf.cast( region_width  \/ pooled_width , 'int32')          areas = [[(                     i*h_step,                      j*w_step,                      (i+1)*h_step if i+1 &lt; pooled_height else region_height,                      (j+1)*w_step if j+1 &lt; pooled_width else region_width                    )                     for j in range(pooled_width)]                    for i in range(pooled_height)]          # take the maximum of each area and stack the result         def pool_area(x):            return tf.math.reduce_max(region[x[0]:x[2], x[1]:x[3], :], axis=[0,1])          pooled_features = tf.stack([[pool_area(x) for x in row] for row in areas])         return pooled_features<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430\u0448\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e! \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e 1-\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 100&#215;200, \u0438 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043c 2 RoI, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0430\u0442\u0447\u0438 \u0434\u043b\u044f \u043f\u0443\u043b\u043b\u0438\u043d\u0433\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 7&#215;3. \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0435\u0433\u0438\u043e\u043d\u044b, \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0432 4 \u043c\u0435\u0442\u043a\u0430\u0445. \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u044b \u043f\u0440\u0438\u0437\u043d\u043e\u043a\u043e\u0432 \u2014 \u0432\u0441\u0435 1, \u043d\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 50 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u043e \u0432 \u0442\u043e\u0447\u043a\u0443 (\u0432\u044b\u0441\u043e\u0442\u0430-1, \u0448\u0438\u0440\u0438\u043d\u0430-3).<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import numpy as np# Define parameters batch_size = 1 img_height = 200 img_width = 100 n_channels = 1 n_rois = 2 pooled_height = 3 pooled_width = 7# Create feature map input feature_maps_shape = (batch_size, img_height, img_width, n_channels) feature_maps_tf = tf.placeholder(tf.float32, shape=feature_maps_shape) feature_maps_np = np.ones(feature_maps_tf.shape, dtype='float32') feature_maps_np[0, img_height-1, img_width-3, 0] = 50 print(f&quot;feature_maps_np.shape = {feature_maps_np.shape}&quot;)# Create batch size roiss_tf = tf.placeholder(tf.float32, shape=(batch_size, n_rois, 4)) roiss_np = np.asarray([[[0.5,0.2,0.7,0.4], [0.0,0.0,1.0,1.0]]], dtype='float32') print(f&quot;roiss_np.shape = {roiss_np.shape}&quot;)# Create layer roi_layer = ROIPoolingLayer(pooled_height, pooled_width) pooled_features = roi_layer([feature_maps_tf, roiss_tf]) print(f&quot;output shape of layer call = {pooled_features.shape}&quot;)# Run tensorflow session with tf.Session() as session:     result = session.run(pooled_features,                           feed_dict={feature_maps_tf:feature_maps_np,                                       roiss_tf:roiss_np})  print(f&quot;result.shape = {result.shape}&quot;) print(f&quot;first  roi embedding=\\n{result[0,0,:,:,0]}&quot;) print(f&quot;second roi embedding=\\n{result[0,1,:,:,0]}&quot;)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0432\u0445\u043e\u0434 \u0434\u043b\u044f \u0441\u043b\u043e\u044f, \u0441\u0442\u0440\u043e\u044f\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u0435\u043d\u0437\u043e\u0440\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0441\u0435\u0430\u043d\u0441 TensorFlow, \u0432 \u0445\u043e\u0434\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u044b\u0432\u043e\u0434\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">feature_maps_np.shape = (1, 200, 100, 1) roiss_np.shape = (1, 2, 4) output shape of layer call = (1, 2, 3, 7, 1) result.shape = (1, 2, 3, 7, 1) first  roi embedding= [[1. 1. 1. 1. 1. 1. 1.]  [1. 1. 1. 1. 1. 1. 1.]  [1. 1. 1. 1. 1. 1. 1.]] second roi embedding= [[ 1.  1.  1.  1.  1.  1.  1.]  [ 1.  1.  1.  1.  1.  1.  1.]  [ 1.  1.  1.  1.  1.  1. 50.]]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0435\u043d\u0437\u043e\u0440\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0430\u0448\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0438 \u2014 \u0432\u0441\u0435 1, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0433\u0434\u0435 \u043c\u044b \u0432\u0432\u0435\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 50.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>  <\/p>\n<h1 id=\"vyvod\">\u0412\u044b\u0432\u043e\u0434<\/h1>\n<p>  <\/p>\n<p>\u0418 \u044d\u0442\u043e \u0432\u0441\u0435 \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u0440\u0435\u0431\u044f\u0442\u0430!<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 ROI Pooling \u0441\u043b\u043e\u0439 \u0438 \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f (<strong>attention<\/strong>). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c Keras \u0434\u043b\u044f \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 \u0441\u043b\u043e\u0451\u0432 \u0431\u0435\u0437 \u0432\u0435\u0441\u043e\u0432, \u0438 \u0434\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0433\u043e ROI Pooling \u0441\u043b\u043e\u044f.<\/p>\n<p>  <\/p>\n<p>\u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0432\u0430\u0441, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0431\u044b\u043b\u043e!<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e Ari Brill, Tjark Miener \u0438 Bryan Kim \u0437\u0430 \u043e\u0442\u0437\u044b\u0432\u044b \u043e \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0438<\/strong><\/p>\n<p>  <\/p>\n<ul>\n<li>Ross Girshick. <a href=\"https:\/\/arxiv.org\/abs\/1504.08083\">Fast R-CNN<\/a>. Proceedings of the IEEE International Conference on Computer Vision. 2015.<\/li>\n<li>Kota Hara, Ming-Yu Liu, Oncel Tuzel, Amir-massoud Farahmand. <a href=\"https:\/\/arxiv.org\/pdf\/1702.01478.pdf\">Attentional Network for Visual Object Detection<\/a>. 2017.<\/li>\n<\/ul>\n<\/div>\n<p> \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\/post\/510094\/\"> https:\/\/habr.com\/ru\/post\/510094\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/510094\/\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/medium.com\/xplore-ai\/implementing-attention-in-tensorflow-keras-using-roi-pooling-992508b6592b\">&quot;Implementing RoI Pooling in TensorFlow + Keras&quot;<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Jaime Sevilla.<\/p>\n<p>  <\/p>\n<p><em>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043f\u0440\u043e\u0445\u043e\u0436\u0443 \u043a\u0443\u0440\u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0412 \u0443\u0447\u0435\u0431\u043d\u043e\u043c \u0431\u043b\u043e\u043a\u0435 &quot;\u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0435 \u0437\u0440\u0435\u043d\u0438\u0435&quot; \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 RoI Pooling \u0441\u043b\u043e\u0451\u0432. \u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u043d\u0438\u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u044f \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c.<\/em><\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u0438 \u043e\u0431\u0449\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 RoI pooling (<strong>Region of Interest<\/strong> \u2014 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432) \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0435\u0432 Keras \u0441\u0440\u0435\u0434\u044b TensorFlow.<\/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-306607","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/306607","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=306607"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/306607\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=306607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=306607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=306607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}