{"id":293955,"date":"2019-08-28T15:00:19","date_gmt":"2019-08-28T15:00:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=293955"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=293955","title":{"rendered":"\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u0446 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0430\u043c\u0441\u043a\u0438\u0445 \u0441\u0435\u0442\u0435\u0439"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mg\/dh\/mb\/mgdhmb0xf-4onn6dny1renuuhla.jpeg\"><\/p>\n<p>  \u0421\u0438\u0430\u043c\u0441\u043a\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0438, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0443\u0447\u0435\u0431\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u0438\u0430\u043c\u0441\u043a\u0430\u044f \u0441\u0435\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0435\u0441\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446 \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 500 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0415\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 (Convolutional Neural Network (CNN)), \u0442\u043e \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 500 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043d\u0430\u043c \u043d\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 CNN \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/www.packtpub.com\/tech\/Deep-Learning\">\u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/a>, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0441\u0438\u0430\u043c\u0441\u043a\u043e\u0439 \u0441\u0435\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u043e \u0441\u0443\u0442\u0438, \u0441\u0438\u0430\u043c\u0441\u043a\u0438\u0435 \u0441\u0435\u0442\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439, \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0432\u0435\u0441\u0430\u043c\u0438 \u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u2014 E. <br \/>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0432 \u0441\u0438\u0430\u043c\u0441\u043a\u043e\u0439 \u0441\u0435\u0442\u0438, \u0441\u043e\u0437\u0434\u0430\u0432 \u043d\u0430 \u0435\u0451 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446. \u041c\u044b \u043d\u0430\u0443\u0447\u0438\u043c \u0435\u0451 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u043b\u0438\u0446\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442. \u0418 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c AT&amp;T Database of Faces, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0441 \u0441\u0430\u0439\u0442\u0430 <a href=\"https:\/\/www.cl.cam.ac.uk\/research\/dtg\/attarchive\/facedatabase.html\">\u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0439 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u0438\u0438 \u041a\u0435\u043c\u0431\u0440\u0438\u0434\u0436\u0441\u043a\u043e\u0433\u043e \u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430<\/a>.<\/p>\n<p>  \u0421\u043a\u0430\u0447\u0430\u043b\u0438, \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043b\u0438 \u0438 \u0432\u0438\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0438 \u043e\u0442 s1 \u0434\u043e s40:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/152\/0fc\/158\/1520fc1584e7ba6335ba2ea99460d8f6.png\"><\/p>\n<p>  \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u043b\u0435\u0436\u0438\u0442 10 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u0441\u043d\u044f\u0442\u044b\u0445 \u0441 \u0440\u0430\u0437\u043d\u044b\u0445 \u0443\u0433\u043b\u043e\u0432. \u0412\u043e\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0430\u043f\u043a\u0438 s1:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5d4\/02b\/86f\/5d402b86fc12e1b23512b1a54c7fea57.png\"><\/p>\n<p>  \u0410 \u0432\u043e\u0442 \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 s13:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b7c\/819\/716\/b7c8197164861f8568e86d32a2294bc2.png\"><\/p>\n<p>  \u0421\u0438\u0430\u043c\u0441\u043a\u0438\u043c \u0441\u0435\u0442\u044f\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0430\u0440\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u044b. \u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0438 \u0434\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438 \u043f\u043e\u043c\u0435\u0442\u0438\u043c \u043a\u0430\u043a \u00ab\u043f\u043e\u0434\u043b\u0438\u043d\u043d\u0443\u044e\u00bb \u043f\u0430\u0440\u0443 (genuine). \u0417\u0430\u0442\u0435\u043c \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u0432\u0435 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0430\u043f\u043e\u043a \u0438 \u043f\u043e\u043c\u0435\u0442\u0438\u043c \u043a\u0430\u043a \u00ab\u043b\u043e\u0436\u043d\u0443\u044e\u00bb \u043f\u0430\u0440\u0443 (imposite):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5b3\/1f3\/8bf\/5b31f38bf3363aaa53110772b7643e3b.png\"><\/p>\n<p>  \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u0432\u0441\u0435 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u043f\u043e \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c, \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u0435\u0442\u0438. \u0418\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u044b \u043c\u044b \u043e\u0434\u043d\u0443 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0441\u0435\u0442\u0438 \u0410, \u0430 \u0432\u0442\u043e\u0440\u0443\u044e \u2014 \u0441\u0435\u0442\u0438 \u0411. \u041e\u0431\u0435 \u0441\u0435\u0442\u0438 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u044f\u043c\u0438 \u0441 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f\u043c\u0438 \u0431\u043b\u043e\u043a\u043e\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u043a\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 (rectified linear unit (ReLU)). \u0418\u0437\u0443\u0447\u0438\u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0435\u0438\u043c\u0438 \u0441\u0435\u0442\u044f\u043c\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044d\u043d\u0435\u0440\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u044b\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c. <\/p>\n<h2>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0441\u0435 \u044d\u0442\u0438 \u044d\u0442\u0430\u043f\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/h2>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">import re import numpy as np from PIL import Image  from sklearn.model_selection import train_test_split from keras import backend as K from keras.layers import Activation from keras.layers import Input, Lambda, Dense, Dropout, Convolution2D, MaxPooling2D, Flatten from keras.models import Sequential, Model from keras.optimizers import RMSprop<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>read_image<\/code> \u0431\u0435\u0440\u0435\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 NumPy-\u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code class=\"python\">def read_image(filename, byteorder='&gt;'):          #first we read the image, as a raw file to the buffer     with open(filename, 'rb') as f:         buffer = f.read()          #using regex, we extract the header, width, height and maxval of the image     header, width, height, maxval = re.search(         b\"(^P5\\s(?:\\s*#.*[\\r\\n])*\"         b\"(\\d+)\\s(?:\\s*#.*[\\r\\n])*\"         b\"(\\d+)\\s(?:\\s*#.*[\\r\\n])*\"         b\"(\\d+)\\s(?:\\s*#.*[\\r\\n]\\s)*)\", buffer).groups()          #then we convert the image to numpy array using np.frombuffer which interprets buffer as one dimensional array     return np.frombuffer(buffer,                             dtype='u1' if int(maxval)<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u044d\u0442\u0443 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e:<\/p>\n<pre><code class=\"python\">Image.open(\"data\/orl_faces\/s1\/1.pgm\")<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ee2\/954\/697\/ee2954697908ce55ffaf4fc8080914c7.png\"><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0435\u0451 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>read_image<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c NumPy-\u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code class=\"python\">img = read_image('data\/orl_faces\/s1\/1.pgm') img.shape (112, 92)<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>get_data<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0441\u0438\u0430\u043c\u0441\u043a\u0438\u043c \u0441\u0435\u0442\u044f\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (genuine \u0438 imposite) \u0441 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (<code>img1<\/code>, <code>img2<\/code>) \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0438\u0445 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <code>x_genuine_pair,<\/code> \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c <code>y_genuine<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>1<\/code>. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (<code>img1<\/code>, <code>img2<\/code>) \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0438\u0445 \u0432 \u043f\u0430\u0440\u0435 <code>x_imposite,<\/code> \u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c <code>y_imposite<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>0<\/code>.<\/p>\n<p>  \u041a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u0435\u043c <code>x_genuine_pair<\/code> \u0438 <code>x_imposite<\/code> \u0432 <code>X<\/code>, \u0430 <code>y_genuine<\/code> \u0438 <code>y_imposite<\/code> \u2014 \u0432 <code>Y<\/code>:<\/p>\n<pre><code class=\"python\">size = 2 total_sample_size = 10000   def get_data(size, total_sample_size):     #read the image     image = read_image('data\/orl_faces\/s' + str(1) + '\/' + str(1) + '.pgm', 'rw+')     #reduce the size     image = image[::size, ::size]     #get the new size     dim1 = image.shape[0]     dim2 = image.shape[1]      count = 0          #initialize the numpy array with the shape of [total_sample, no_of_pairs, dim1, dim2]     x_geuine_pair = np.zeros([total_sample_size, 2, 1, dim1, dim2]) # 2 is for pairs     y_genuine = np.zeros([total_sample_size, 1])          for i in range(40):         for j in range(int(total_sample_size\/40)):             ind1 = 0             ind2 = 0                          #read images from same directory (genuine pair)             while ind1 == ind2:                 ind1 = np.random.randint(10)                 ind2 = np.random.randint(10)                          # read the two images             img1 = read_image('data\/orl_faces\/s' + str(i+1) + '\/' + str(ind1 + 1) + '.pgm', 'rw+')             img2 = read_image('data\/orl_faces\/s' + str(i+1) + '\/' + str(ind2 + 1) + '.pgm', 'rw+')                          #reduce the size             img1 = img1[::size, ::size]             img2 = img2[::size, ::size]                          #store the images to the initialized numpy array             x_geuine_pair[count, 0, 0, :, :] = img1             x_geuine_pair[count, 1, 0, :, :] = img2                          #as we are drawing images from the same directory we assign label as 1. (genuine pair)             y_genuine[count] = 1             count += 1      count = 0     x_imposite_pair = np.zeros([total_sample_size, 2, 1, dim1, dim2])     y_imposite = np.zeros([total_sample_size, 1])          for i in range(int(total_sample_size\/10)):         for j in range(10):                          #read images from different directory (imposite pair)             while True:                 ind1 = np.random.randint(40)                 ind2 = np.random.randint(40)                 if ind1 != ind2:                     break                                  img1 = read_image('data\/orl_faces\/s' + str(ind1+1) + '\/' + str(j + 1) + '.pgm', 'rw+')             img2 = read_image('data\/orl_faces\/s' + str(ind2+1) + '\/' + str(j + 1) + '.pgm', 'rw+')              img1 = img1[::size, ::size]             img2 = img2[::size, ::size]              x_imposite_pair[count, 0, 0, :, :] = img1             x_imposite_pair[count, 1, 0, :, :] = img2             #as we are drawing images from the different directory we assign label as 0. (imposite pair)             y_imposite[count] = 0             count += 1                  #now, concatenate, genuine pairs and imposite pair to get the whole data     X = np.concatenate([x_geuine_pair, x_imposite_pair], axis=0)\/255     Y = np.concatenate([y_genuine, y_imposite], axis=0)      return X, Y<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440. \u0423 \u043d\u0430\u0441 20 000 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0431\u0440\u0430\u043d\u043e 10 000 \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0438 10 000 \u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0430\u0440:<\/p>\n<pre><code class=\"python\">X, Y = get_data(size, total_sample_size)  X.shape (20000, 2, 1, 56, 46)  Y.shape (20000, 1)<\/code><\/pre>\n<p>  \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0432\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438: 75 % \u043f\u0430\u0440 \u043f\u043e\u0439\u0434\u0435\u0442 \u043d\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435, \u0430 25 % \u2014 \u043d\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435:<br \/>  <code>x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=.25)<\/code><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0438\u0430\u043c\u0441\u043a\u0443\u044e \u0441\u0435\u0442\u044c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0435\u0442\u044c \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ReLU-\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0439 \u0438 \u0441\u043b\u043e\u044f \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (max pooling) \u043f\u043e\u0441\u043b\u0435 flat-\u0441\u043b\u043e\u044f:<\/p>\n<pre><code class=\"python\">def build_base_network(input_shape):          seq = Sequential()          nb_filter = [6, 12]     kernel_size = 3               #convolutional layer 1     seq.add(Convolution2D(nb_filter[0], kernel_size, kernel_size, input_shape=input_shape,                           border_mode='valid', dim_ordering='th'))     seq.add(Activation('relu'))     seq.add(MaxPooling2D(pool_size=(2, 2)))      seq.add(Dropout(.25))          #convolutional layer 2     seq.add(Convolution2D(nb_filter[1], kernel_size, kernel_size, border_mode='valid', dim_ordering='th'))     seq.add(Activation('relu'))     seq.add(MaxPooling2D(pool_size=(2, 2), dim_ordering='th'))      seq.add(Dropout(.25))      #flatten      seq.add(Flatten())     seq.add(Dense(128, activation='relu'))     seq.add(Dropout(0.1))     seq.add(Dense(50, activation='relu'))     return seq<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u0440\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0435\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432:<\/p>\n<pre><code class=\"python\">input_dim = x_train.shape[2:] img_a = Input(shape=input_dim) img_b = Input(shape=input_dim)  base_network = build_base_network(input_dim) feat_vecs_a = base_network(img_a) feat_vecs_b = base_network(img_b) <\/code><\/pre>\n<p>  <code>feat_vecs_a<\/code> \u0438 <code>feat_vecs_b<\/code> \u2014 \u044d\u0442\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043f\u0430\u0440\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0410 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u044b\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"python\">def euclidean_distance(vects):     x, y = vects     return K.sqrt(K.sum(K.square(x - y), axis=1, keepdims=True))   def eucl_dist_output_shape(shapes):     shape1, shape2 = shapes     return (shape1[0], 1)  distance = Lambda(euclidean_distance, output_shape=eucl_dist_output_shape)([feat_vecs_a, feat_vecs_b])<\/code><\/pre>\n<p>  \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0447\u0438\u0441\u043b\u043e \u044d\u043f\u043e\u0445 \u0440\u0430\u0432\u043d\u044b\u043c 13, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e RMS \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code class=\"python\">epochs = 13 rms = RMSprop()  model = Model(input=[input_a, input_b], output=distance)<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c <code>contrastive_loss<\/code> function \u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code class=\"python\">def contrastive_loss(y_true, y_pred):     margin = 1     return K.mean(y_true * K.square(y_pred) + (1 - y_true) * K.square(K.maximum(margin - y_pred, 0)))  model.compile(loss=contrastive_loss, optimizer=rms)<\/code><\/pre>\n<p>  \u0417\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">img_1 = x_train[:, 0] img_2 = x_train[:, 1]   model.fit([img_1, img_2], y_train, validation_split=.25, batch_size=128, verbose=2, nb_epoch=epochs)<\/code><\/pre>\n<p>  \u0412\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u043f\u043e\u0442\u0435\u0440\u0438 \u0441\u043d\u0438\u0436\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u043f\u043e\u0445:<\/p>\n<pre><code class=\"python\">Train on 11250 samples, validate on 3750 samples Epoch 1\/13  - 60s - loss: 0.2179 - val_loss: 0.2156 Epoch 2\/13  - 53s - loss: 0.1520 - val_loss: 0.2102 Epoch 3\/13  - 53s - loss: 0.1190 - val_loss: 0.1545 Epoch 4\/13  - 55s - loss: 0.0959 - val_loss: 0.1705 Epoch 5\/13  - 52s - loss: 0.0801 - val_loss: 0.1181 Epoch 6\/13  - 52s - loss: 0.0684 - val_loss: 0.0821 Epoch 7\/13  - 52s - loss: 0.0591 - val_loss: 0.0762 Epoch 8\/13  - 52s - loss: 0.0526 - val_loss: 0.0655 Epoch 9\/13  - 52s - loss: 0.0475 - val_loss: 0.0662 Epoch 10\/13  - 52s - loss: 0.0444 - val_loss: 0.0469 Epoch 11\/13  - 52s - loss: 0.0408 - val_loss: 0.0478 Epoch 12\/13  - 52s - loss: 0.0381 - val_loss: 0.0498 Epoch 13\/13  - 54s - loss: 0.0356 - val_loss: 0.0363<\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"python\">pred = model.predict([x_test[:, 0], x_test[:, 1]])<\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"python\">def compute_accuracy(predictions, labels):     return labels[predictions.ravel()<\/code><\/pre>\n<p>  \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"plaintext\">compute_accuracy(pred, y_test)  0.9779092702169625 <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0438\u0430\u043c\u0441\u043a\u0438\u0445 \u0441\u0435\u0442\u0435\u0439. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0442\u0430\u043a\u0438\u0445 \u0441\u0435\u0442\u0435\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439, \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u043e\u0434\u0438\u043d \u0432\u0435\u0441 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u2014 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043c\u0435\u0442\u0430\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e<a href=\"https:\/\/subscribe.packtpub.com\/learn-python\/\"> Python<\/a> \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0432 \u043a\u043d\u0438\u0433\u0435 <a href=\"https:\/\/www.packtpub.com\/big-data-and-business-intelligence\/hands-meta-learning-python\">Hands-On Meta-Learning with Python.<\/a><\/p>\n<h2>\u041c\u043e\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/h2>\n<p>  \u0417\u043d\u0430\u043d\u0438\u0435 \u0441\u0438\u0430\u043c\u0441\u043a\u0438\u0439 \u0441\u0435\u0442\u0435\u0439 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0441\u0435\u0442\u0435\u0439 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u0435\u0442\u043e\u0434\u044b \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438. \u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u00ab\u0434\u0435\u0448\u0435\u0432\u043e\u00bb \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u0432\u043e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0438\u0430\u043c\u0441\u043a\u043e\u0439 \u0441\u0435\u0442\u0438 \u043d\u0430 \u00abHello world\u00bb \u0434\u043b\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u2014 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 MNIST <a href=\"https:\/\/keras.io\/examples\/mnist_siamese\/\">keras.io\/examples\/mnist_siamese<\/a><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/jetinfosystems\/blog\/465279\/\"> https:\/\/habr.com\/ru\/company\/jetinfosystems\/blog\/465279\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mg\/dh\/mb\/mgdhmb0xf-4onn6dny1renuuhla.jpeg\"><\/p>\n<p>  \u0421\u0438\u0430\u043c\u0441\u043a\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0438, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0443\u0447\u0435\u0431\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u0438\u0430\u043c\u0441\u043a\u0430\u044f \u0441\u0435\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0435\u0441\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446 \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 500 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0415\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 (Convolutional Neural Network (CNN)), \u0442\u043e \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 500 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043d\u0430\u043c \u043d\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 CNN \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/www.packtpub.com\/tech\/Deep-Learning\">\u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/a>, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0441\u0438\u0430\u043c\u0441\u043a\u043e\u0439 \u0441\u0435\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043c\u0435\u043d\u044c\u0448\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.  <\/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-293955","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293955","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=293955"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293955\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}