{"id":294714,"date":"2019-11-17T15:01:40","date_gmt":"2019-11-17T15:01:40","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=294714"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=294714","title":{"rendered":"\u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0445\u0435\u0439\u0442\u0435\u0440\u043e\u0432 \u2014 \u00ab\u043d\u0435, \u043d\u0443 \u044d\u0442\u043e \u0431\u0430\u043d\u00bb"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\">\u041f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  \u0427\u0430\u0441\u0442\u043e \u043b\u0438 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u043e\u043a\u0441\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0432 \u0441\u043e\u0446\u0441\u0435\u0442\u044f\u0445? \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0448\u044c. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0438 \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0445\u0435\u0439\u0442\u0435\u0440\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0448\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439. \u041c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c, \u043e\u0431\u0443\u0447\u0438\u043c \u0435\u0435 \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043e\u0446\u0441\u0435\u0442\u0435\u0439, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Google Colab. \u042d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c Jupyter Notebook&#8217;\u0438, \u0438\u043c\u0435\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a GPU (NVidia Tesla K80) \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e, \u0447\u0442\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435. \u041c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f backend TensorFlow, \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432 Colab 1.15.0, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0434\u043e 2.0.0. <\/p>\n<p>  \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<pre><code class=\"python\">from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf !tf_upgrade_v2 -h<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a.<\/p>\n<pre><code class=\"python\">print(tf.__version__)<\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0434\u0435\u043b\u0430\u043d\u044b, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/p>\n<pre><code class=\"python\">import os  import numpy as np  # For DataFrame object import pandas as pd  # Neural Network from keras.models import Sequential from keras.layers import Dense, Dropout from keras.optimizers import RMSprop  # Text Vectorizing from keras.preprocessing.text import Tokenizer  # Train-test-split from sklearn.model_selection import train_test_split  # History visualization %matplotlib inline import matplotlib.pyplot as plt  # Normalize from sklearn.preprocessing import normalize <\/code><\/pre>\n<h2>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h2>\n<ul>\n<li>os \u2014 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>numpy \u2014 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>pandas \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>keras \u2014 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>keras.preprocessing.Text \u2014 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>sklearn.train_test_split \u2014 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>matplotlib \u2014 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>sklearn.normalize \u2014 \u0434\u043b\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0438 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0420\u0430\u0437\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 Kaggle<\/h2>\n<p>  \u042f \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u044f\u043c\u043e \u0432 \u0441\u0430\u043c Colab-\u043d\u043e\u0443\u0442\u0431\u0443\u043a. \u0414\u0430\u043b\u0435\u0435 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438\u0445 \u0443\u0436\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e.<\/p>\n<pre><code class=\"python\">path = 'labeled.csv' df = pd.read_csv(path) df.head()<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7e\/is\/vk\/7eisvkltuwv5hhe0ir5oopolmx4.png\"><\/p>\n<p>  \u0418 \u044d\u0442\u043e \u0448\u0430\u043f\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u2026 \u041c\u043d\u0435 \u0442\u043e\u0436\u0435 \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u0442 \u00ab\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043e\u0431\u043d\u043e\u0432\u0438, \u0434\u0435\u0431\u0438\u043b\u00bb.<br \/>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043c\u044b \u0435\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438: \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0438. \u041d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0442\u0435\u043a\u0441\u0442, \u043d\u0430\u0434\u043e \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  \u0423\u0434\u0430\u043b\u0438\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<pre><code class=\"python\">def delete_new_line_symbols(text):     text = text.replace('\\n', ' ')     return text<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">df['comment'] = df['comment'].apply(delete_new_line_symbols) df.head()<\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438\u043c\u0435\u044e\u0442 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439. \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<pre><code class=\"python\">target = np.array(df['toxic'].astype('uint8')) target[:5]<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 Tokenizer. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440.<\/p>\n<pre><code class=\"python\">tokenizer = Tokenizer(num_words=30000, filters='!\"#$%&amp;()*+,-.\/:;&lt;=&gt;?@[\\\\]^_`{|}~\\t\\n',                        lower=True,                        split=' ',                        char_level=False)<\/code><\/pre>\n<p>  <b>\u0411\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/b><\/p>\n<ul>\n<li>num_words \u2014 \u043a\u043e\u043b-\u0432\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0441\u043b\u043e\u0432 (\u0441\u0430\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f)<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>filters \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>lower \u2014 \u0431\u0443\u043b\u0435\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0442\u043e, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0451\u043d \u0442\u0435\u043a\u0441\u0442 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>split \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/li>\n<\/ul>\n<p>  <\/p>\n<ul>\n<li>char_level \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u043b\u043e\u0432\u043e\u043c<\/li>\n<\/ul>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<pre><code class=\"python\">tokenizer.fit_on_texts(df['comment']) matrix = tokenizer.texts_to_matrix(df['comment'], mode='count') matrix.shape<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 14\u043a \u0441\u0442\u0440\u043e\u043a-\u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0438 30\u043a \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432-\u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/4z\/iz\/ji\/4zizjiclkgiyu__wmblolopw3ri.png\"><\/p>\n<p>  \u042f \u0441\u0442\u0440\u043e\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0451\u0432: Dense \u0438 Dropout.<\/p>\n<pre><code class=\"python\">def get_model():          model = Sequential()          model.add(Dense(32, activation='relu'))     model.add(Dropout(0.3))     model.add(Dense(16, activation='relu'))     model.add(Dropout(0.3))     model.add(Dense(16, activation='relu'))     model.add(Dense(1, activation='sigmoid'))          model.compile(optimizer=RMSprop(lr=0.0001),                    loss='binary_crossentropy',                   metrics=['accuracy'])          return model<\/code><\/pre>\n<p>  \u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0438 \u0440\u0430\u0437\u043e\u0431\u044c\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438, \u043a\u0430\u043a \u0438 \u0434\u043e\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u043b\u0438\u0441\u044c (\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u0441\u0442).<\/p>\n<pre><code class=\"python\">X = normalize(matrix) y = target  X_train, X_test, y_train, y_test = train_test_split(X,                                                      y,                                                     test_size=0.2)  X_train.shape, y_train.shape<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>  <\/p>\n<pre><code class=\"python\">model = get_model()  history = model.fit(X_train,                      y_train,                      epochs=150,                      batch_size=500,                     validation_data=(X_test, y_test))  history<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f\u0445.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/n5\/p8\/ko\/n5p8ko8tp68sz-tb3bgtrtmyhx4.png\"><\/p>\n<h2>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<pre><code class=\"python\">history = history.history  fig = plt.figure(figsize=(20, 10))  ax1 = fig.add_subplot(221) ax2 = fig.add_subplot(223)  x = range(150)  ax1.plot(x, history['acc'], 'b-', label='Accuracy') ax1.plot(x, history['val_acc'], 'r-', label='Validation accuracy') ax1.legend(loc='lower right')  ax2.plot(x, history['loss'], 'b-', label='Losses') ax2.plot(x, history['val_loss'], 'r-', label='Validation losses') ax2.legend(loc='upper right')<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tg\/1p\/bn\/tg1pbntyktgpmnckeeiqbizub9k.png\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/j0\/gh\/lb\/j0ghlbxyvtctsrvtrwrweuw0vwa.png\"><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u0448\u043b\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0430 75-\u043e\u0439 \u044d\u043f\u043e\u0445\u0435, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f \u043f\u043b\u043e\u0445\u043e. \u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 0,85 \u043d\u0435 \u043e\u0433\u043e\u0440\u0447\u0430\u0435\u0442. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0440\u0430\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u043b\u043e\u0435\u0432, \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u042d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0442\u044b. \u041e \u0441\u0432\u043e\u0438\u0445 \u043c\u044b\u0441\u043b\u044f\u0445 \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u044b, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u0435\u0439\u0442\u0430 \u043d\u0430\u0431\u0435\u0440\u0435\u0442 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f.<\/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\/post\/476188\/\"> https:\/\/habr.com\/ru\/post\/476188\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\">\u041f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  \u0427\u0430\u0441\u0442\u043e \u043b\u0438 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u043e\u043a\u0441\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0432 \u0441\u043e\u0446\u0441\u0435\u0442\u044f\u0445? \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0448\u044c. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0438 \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0445\u0435\u0439\u0442\u0435\u0440\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0448\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439. \u041c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c, \u043e\u0431\u0443\u0447\u0438\u043c \u0435\u0435 \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043e\u0446\u0441\u0435\u0442\u0435\u0439, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Google Colab. \u042d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c Jupyter Notebook&#8217;\u0438, \u0438\u043c\u0435\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a GPU (NVidia Tesla K80) \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e, \u0447\u0442\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435. \u041c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f backend TensorFlow, \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432 Colab 1.15.0, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0434\u043e 2.0.0. <\/p>\n<p>  \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c.<\/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-294714","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294714","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=294714"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294714\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}