{"id":305095,"date":"2020-06-09T15:00:51","date_gmt":"2020-06-09T15:00:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305095"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305095","title":{"rendered":"\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e-\u0441\u043e\u0441\u0442\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 (GAN)"},"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\/506032\/\">\u0414\u043b\u044f \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0440\u0435\u0434\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0441\u0442\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (GAN) \u043f\u043e\u0440\u0430\u0436\u0430\u0435\u0442 \u0438 \u0434\u0430\u0451\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/436088\/\">\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f<\/a> \u0438 \u0434\u0430\u0436\u0435 <a href=\"https:\/\/thispersondoesnotexist.com\/\">\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e<\/a> \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430.<br \/>  \u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f. \u0417\u0434\u0435\u0441\u044c \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u043e\u0434\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043e\u0441\u0442\u0440\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f\u0445 \u0438 \u0442\u0440\u044e\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.<\/p>\n<p>  \u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0432\u0437\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 <a href=\"https:\/\/www.tensorflow.org\/tutorials\/generative\/dcgan\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 tensorflow<\/a> \u0438 <a href=\"https:\/\/neurohive.io\/ru\/tutorial\/simple-gan-python-keras\/\">\u043a\u043e\u0434 \u043d\u0430 keras<\/a>. \u041e\u043d\u0438 \u043e\u0431\u0430 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u043d\u043e \u043a\u0430\u043a \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c \u043d\u0438\u0436\u0435, \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b. \u0418\u0434\u0435\u0438 \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/machinelearningmastery.com\/how-to-train-stable-generative-adversarial-networks\/\">Tips for GAN<\/a> \u0438 \u0438\u0437 <a href=\"https:\/\/arxiv.org\/pdf\/1511.06434.pdf\">\u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e GAN<\/a>.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e 2 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: numpy \u0438 tensorflow \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 GIF \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u043e \u0432 jupyter notebook.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h4>\n<p>  <\/p>\n<pre><code class=\"python\">#python 3.6 !pip install tensorflow==2.0.0 !pip install numpy==1.18.1 !pip install imageio==2.6.1 !pip install matplotlib==3.1.2 !pip install tqdm==4.41.1<\/code><\/pre>\n<h4>\u0418\u043c\u043f\u043e\u0440\u0442\u044b<\/h4>\n<p>  <\/p>\n<pre><code class=\"python\">import tensorflow as tf import numpy as np from tensorflow.keras.layers import Input, BatchNormalization, LeakyReLU, Reshape from tensorflow.keras.layers import Conv2D, Conv2DTranspose, Activation, Concatenate from tensorflow.keras.layers import Dense, Flatten, Dropout from tensorflow.keras.models import Model from tensorflow.keras.utils import to_categorical from tqdm.notebook import tqdm #\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f GIF import imageio from IPython.display import Image import matplotlib.pyplot as plt import os <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  <\/p>\n<pre><code class=\"python\">DEPTH = 10 (train_images, train_labels), (_, _) = tf.keras.datasets.mnist.load_data() train_images = train_images.reshape(train_images.shape[0], 28, 28, 1).astype('float32') train_images = train_images \/ 255 # \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 [0, 1] train_labels = np.array(to_categorical(train_labels, DEPTH)) <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  <b>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f:<\/b><\/p>\n<ul>\n<li>\u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u0445 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u043b\u0443\u0447\u0448\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0441\u0444\u0435\u0440\u044b (\u0442.\u0435. \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c), \u043d\u043e \u043e\u043f\u044b\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0434\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f;<\/li>\n<li>\u044f\u0440\u043b\u044b\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438 \u0435\u0451 \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c;<\/li>\n<li>\u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0430\u0442\u0447\u0435\u0439 \u0432 \u044d\u043f\u043e\u0445\u0435;<\/li>\n<li>\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e tqdm \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0430 \u044d\u043f\u043e\u0445\u0438;<\/li>\n<li>\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0443\u0434\u0443\u0442 \u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e;<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"python\">RANDOM_DIM = 100  class DataGenerator():     def __init__(self, train_images, train_labels, batches_per_epoch, batch_size):         self.train_images = train_images         self.train_labels = train_labels         self.batches_per_epoch = batches_per_epoch         self.batch_size = batch_size          @staticmethod     def rand_norm(npoints=1, ndim=RANDOM_DIM):         rand_vec = np.random.normal(0, 1, size=[npoints, ndim])         # \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u044f \u043d\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u0441\u0444\u0435\u0440\u044b         # rand_vec = rand_vec \/ np.sqrt(np.sum(np.square(rand_vec), axis=1))[:, np.newaxis]         return rand_vec      def __len__(self):         return self.batches_per_epoch          def batch(self):         rand_images_indexes = np.random.randint(0, train_images.shape[0], size=self.batch_size)         image_batch = train_images[rand_images_indexes]         labels_batch = train_labels[rand_images_indexes]         return image_batch, labels_batch          def __iter__(self):         for b in tqdm(range(self.batches_per_epoch), leave=False):             yield self.batch()                  def rand_batch(self):         rand_vec = self.rand_norm(self.batch_size)         rand_labels = np.random.randint(0, 10, size=[self.batch_size])         rand_labels = np.array(to_categorical(rand_labels, DEPTH))         return [rand_vec, rand_labels]  np.random.seed(42) images_indexes = np.random.randint(0, len(train_images), size=16) PICS_FROM_DATASET = [train_images[images_indexes], train_labels[images_indexes]] FIXED_NOISE = [DataGenerator.rand_norm(16), train_labels[images_indexes]] <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/h2>\n<p>  <b>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f:<\/b><\/p>\n<ul>\n<li>\u043e\u0434\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f complexity \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0430\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0438 \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u0435 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430;<\/li>\n<li>\u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0435\u0441\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438;<\/li>\n<li>\u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043b\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0430\u0442\u0447\u0430;<\/li>\n<li>\u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f Conv2DTranspose;<\/li>\n<li>\u043e\u043f\u044b\u0442\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c \u0431\u044b\u043b\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e, \u0447\u0442\u043e \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u2018sigmoid\u2019 \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0441\u043b\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c \u2018tanh&#8217;, \u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u0435\u0442\u0438;<\/li>\n<li>\u043e\u043f\u0442\u0438\u043c\u0430\u0439\u0437\u0435\u0440 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 sgd;<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"python\">def make_generator():     complexity = 80     alpha = 0.2          random_vector = Input(shape=[RANDOM_DIM])     labels = Input(shape=[DEPTH])          X = Concatenate()([random_vector, labels])     # 1 \u0441\u043b\u043e\u0439     X = Dense(7 * 7 * int(complexity\/2),                           input_dim=RANDOM_DIM,                           kernel_initializer=tf.keras.initializers.RandomNormal(stddev=0.02))(X)     X = BatchNormalization()(X)     X = LeakyReLU(alpha)(X)          X = Reshape((7, 7, int(complexity\/2)))(X)          # 2 \u0441\u043b\u043e\u0439     X = Conv2DTranspose(int(complexity),                          kernel_size=(5, 5),                         strides=(2, 2),                         padding='same')(X)     X = BatchNormalization()(X)     X = LeakyReLU(alpha)(X)      # 3 \u0441\u043b\u043e\u0439     X = Conv2DTranspose(int(complexity),                         kernel_size=(5, 5),                         strides=(1, 1),                         padding='same')(X)     X = BatchNormalization()(X)     X = LeakyReLU(alpha)(X)          # 4 \u0441\u043b\u043e\u0439     X = Conv2DTranspose(int(complexity),                         kernel_size=(5, 5),                         strides=(1, 1),                         padding='same')(X)     X = BatchNormalization()(X)     X = LeakyReLU(alpha)(X)          # 5 \u0441\u043b\u043e\u0439     X = Conv2DTranspose(int(complexity),                         kernel_size=(5, 5),                         strides=(1, 1),                         padding='same')(X)     X = BatchNormalization()(X)     X = LeakyReLU(alpha)(X)          # 6 \u0441\u043b\u043e\u0439     X = Conv2DTranspose(1,                         kernel_size=(5, 5),                         strides=(2, 2),                         padding='same')(X)     X = Activation('sigmoid')(X)          model = Model(inputs=[random_vector, labels], outputs=X, name='generator')     model.compile(loss='binary_crossentropy',                   metrics=['acc'],                   optimizer='sgd')     model.summary()     return model generator = make_generator()<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0422\u0435\u0441\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430<\/h3>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043d\u0435 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043e\u043d\u0430 \u0440\u0438\u0441\u0443\u0435\u0442 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443 16 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 16 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def mkdir_p(path):     try:         os.makedirs(path)     except OSError:         print('Folder already exists')  def plot_and_save_images(generated_images, folder_name, title, cols, rows, figsize, show=False, subtitles=False):     fig, axs = plt.subplots(rows, cols, constrained_layout=True)     fig.set_figheight(figsize[0])     fig.set_figwidth(figsize[1])     for i in range(rows):         for j in range(cols):             axs[i][j].imshow(generated_images[i][j], interpolation='nearest', cmap='gray_r')             axs[i][j].axis('off')             if not subtitles is None:                 if i == 0 and j == 0:                     axs[i][j].set_title(subtitles[0], fontsize=10)                 if i == int(rows\/2) and j == 0:                     axs[i][j].set_title(subtitles[1], fontsize=10)          fig.suptitle(title, fontsize=12)     plt.savefig(os.path.join(folder_name, title + '.png'))     if show:         plt.show()     plt.close()   def plot_generated_images(noise, folder_name, title, cols=8, rows=4, figsize=(4, 8), show=False, subtitles=('generated', 'dataset')):     generated_images = generator.predict(noise)     images = np.concatenate([generated_images, PICS_FROM_DATASET[0]])     images = images.reshape(rows, cols, 28, 28)     plot_and_save_images(images, folder_name, title, cols, rows, figsize, show, subtitles)       folder_name = 'GAN_pics_for_gif' mkdir_p(os.path.join(folder_name))  title = f&quot;DCGAN training process {0} epochs&quot; plot_generated_images(FIXED_NOISE, folder_name, title, show=True)<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0414\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u0439\u0437\u0435\u0440 adam \u0441 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 learning_rate \u0438 beta_1. <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def optimizer():     return tf.keras.optimizers.Adam(lr=0.0002, beta_1=0.5)<\/code><\/pre>\n<p>  <b>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f:<\/b>  <\/p>\n<ul>\n<li>\u043e\u0434\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f complexity \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0430\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 =&gt; \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u0435 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430;<\/li>\n<li>\u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440 \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0446\u0438\u0444\u0440\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439, \u043d\u043e \u0438 \u043c\u0435\u0442\u043a\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f;<\/li>\n<li>\u0434\u043b\u044f \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0430\u0442\u0447\u0430;<\/li>\n<li>\u0434\u043b\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 LeakyReLU c alpha=0.2 (LeakyReLU \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0431\u044f \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c &#8216;ReLU&#8217; \u0438 &#8216;elu&#8217;;<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0430 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440 (\u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e) \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430. <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def make_discriminator():     complexity = 70     drop_rate = 0.2     alpha = 0.2          inp = Input(shape=(28, 28, 1))     X = inp     # 1 \u0441\u043b\u043e\u0439     X = Conv2D(int(complexity\/4),                kernel_size=(5, 5),                strides=(2, 2),                kernel_initializer=tf.keras.initializers.RandomNormal(stddev=0.02),                padding='same')(X)     X = LeakyReLU(alpha)(X)     X = Dropout(drop_rate)(X)          # 2 \u0441\u043b\u043e\u0439     X = Conv2D(int(complexity\/2),                kernel_size=(5, 5),                strides=(2, 2),                #kernel_initializer=tf.keras.initializers.RandomNormal(stddev=0.02),                padding='same')(X)     X = LeakyReLU(alpha)(X)     X = Dropout(drop_rate)(X)          # 3 \u0441\u043b\u043e\u0439     X = Conv2D(int(complexity),                kernel_size=(5, 5),                strides=(2, 2),                #kernel_initializer=tf.keras.initializers.RandomNormal(stddev=0.02),                padding='same')(X)     X = LeakyReLU(alpha)(X)     X = Dropout(drop_rate)(X)          # 4 \u0441\u043b\u043e\u0439     X = Conv2D(int(2*complexity),                kernel_size=(5, 5),                strides=(1, 1),                #kernel_initializer=tf.keras.initializers.RandomNormal(stddev=0.02),             padding='same')(X)     X = LeakyReLU(alpha)(X)     X = Dropout(drop_rate)(X)          # 5 \u0441\u043b\u043e\u0439     X = Conv2D(int(complexity),                kernel_size=(5, 5),                strides=(1, 1),                #kernel_initializer=tf.keras.initializers.RandomNormal(stddev=0.02),                padding='same')(X)     X = LeakyReLU(alpha)(X)     X = Dropout(drop_rate)(X)      # 6 \u0441\u043b\u043e\u0439     X = Flatten()(X)     X_real_fake = Dense(1, activation='sigmoid', name='real_fake')(X)     # 6 \u0441\u043b\u043e\u0439     X_labels = Dense(DEPTH, activation='softmax', name='labels')(X)          model = Model(inputs=inp, outputs=[X_real_fake, X_labels], name='discriminator')     model.compile(loss={'real_fake': 'binary_crossentropy',                         'labels': 'categorical_crossentropy'},                   loss_weights={'real_fake':1,                                 'labels': 1},                   optimizer=optimizer(),                   metrics={'real_fake':'acc'})          model.summary()     return model discriminator = make_discriminator()<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0422\u0435\u0441\u0442 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">discriminator.predict(generator.predict(FIXED_NOISE))<\/code><\/pre>\n<h2>\u0421\u0431\u043e\u0440\u043a\u0430 GAN<\/h2>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0435\u0439 GAN.<\/p>\n<pre><code class=\"python\">def make_gan(discriminator, generator):        noise = generator.inputs     image = generator(noise)     real_vs_fake_and_label = discriminator(image)     gan = Model(inputs=noise, outputs=real_vs_fake_and_label)     # \u043d\u0430\u0434\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0435\u0439     # \u0442.\u043a. \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c GAN \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430     discriminator.trainable = False       gan.compile(loss={'discriminator':'binary_crossentropy',                       'discriminator_1':'categorical_crossentropy'},                                  optimizer=optimizer(),                 metrics={'discriminator':'acc'})     discriminator.trainable = True     gan.summary()     return gan gan = make_gan(discriminator, generator)<\/code><\/pre>\n<h2>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <b>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430:<\/b><\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u0430\u0442\u0447 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430<\/li>\n<li>\u0414\u0435\u043b\u0430\u0435\u043c \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u043a<\/li>\n<li>\u041e\u0431\u0443\u0447\u0430\u0435\u043c \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440<\/li>\n<\/ol>\n<p>  <b>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430:<\/b><\/p>\n<ol>\n<li>\u0417\u0430\u0434\u0430\u0451\u043c \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0434\u043b\u044f GAN<\/li>\n<li>\u041e\u0431\u0443\u0447\u0430\u0435\u043c GAN(\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440) \u043d\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0435<\/li>\n<\/ol>\n<p>  <b>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f:<\/b><\/p>\n<ul>\n<li>\u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u0430\u043a \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445;<\/li>\n<li>\u0442.\u043a. \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u044f\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e, \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0442\u0447\u0435\u0439 \u0432 \u044d\u043f\u043e\u0445\u0443;<\/li>\n<li>\u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0445\u043e\u0440\u043e\u0448\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u00ab\u043e\u0431\u043c\u0430\u043d\u044b\u0432\u0430\u0435\u0442\u00bb \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440. \u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0431\u044b \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0431\u044b\u043b\u0430 \u0440\u043e\u0432\u043d\u0430 50%;<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"python\">EPOCHS = 500 BATCH_SIZE = 128 data = DataGenerator(train_images, train_labels, batches_per_epoch=40, batch_size=BATCH_SIZE) #\u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f generator_acc_follow = [] for epoch in tqdm(range(1, EPOCHS+1)):     for images_batch, labels_batch in data:         # \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430         noise = data.rand_batch()         generated_images = generator.predict(noise)         X = np.concatenate([images_batch, generated_images])         # \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439         y_real = np.random.uniform(0.8, 1, size=[BATCH_SIZE])         y_fake = np.random.uniform(0, 0.2, size=[BATCH_SIZE])         y_real_fake = np.concatenate([y_real, y_fake])         # \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u043a         y_labels = np.concatenate([labels_batch, np.zeros((BATCH_SIZE, DEPTH))])         # \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440         discriminator.train_on_batch(X, [y_real_fake, y_labels])                  # \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430         noise = data.rand_batch()         # \u0437\u0430\u0434\u0430\u0451\u043c \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f         y_real_fake = np.ones(BATCH_SIZE)         y_labels = np.zeros((BATCH_SIZE, DEPTH))         # \u043e\u0431\u0443\u0447\u0430\u0435\u043c GAN \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432         generator_acc_follow.append(gan.train_on_batch(noise, [y_real_fake, noise[1]])[-1])      # \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f .gif     title = f&quot;DCGAN training process {epoch} over {EPOCHS} epochs&quot;     if epoch%int(EPOCHS\/40)==0:         plot_generated_images(FIXED_NOISE, folder_name, title, show=True)         print('\u0435\u0441\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0438 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440 \u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0442\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u0432 0 \u0438\u043b\u0438 1:')         print(np.mean(generator_acc_follow))         generator_acc_follow = []     else:         plot_generated_images(FIXED_NOISE, folder_name, title)          generator.save('generator_trained.h5')<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 .gif \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<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">for folder_data in os.walk(os.path.join(folder_name)):     all_pics_filenames = sorted(folder_data[2], key=lambda x: int(x.split()[3]))  with imageio.get_writer('DCGAN training.gif', mode='I', fps=60) as writer:     for filename in tqdm(all_pics_filenames):         image = imageio.imread(os.path.join(folder_name, filename))         writer.append_data(image)          with open('DCGAN training.gif','rb') as f:     display(Image(data=f.read(), format='png'))<\/code><\/pre>\n<p>  \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:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9r\/aa\/u2\/9raau2sng7te4sxqbbc82qasyks.gif\" alt=\"image\"\/><\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>  <\/p>\n<p>\u0418\u043c\u0435\u044f \u0432\u0441\u0435\u0433\u043e 1.3\u041c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, GAN \u0447\u0435\u0440\u0435\u0437 5000 \u0431\u0430\u0442\u0447\u0435\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0430 \u0447\u0435\u0440\u0435\u0437 20000 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u043c\u044b\u0435 \u043e\u0442 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0431\u043e\u043d\u0443\u0441 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u0446\u0438\u0444\u0440\u0443.<\/p>\n<p>  <\/p>\n<p>\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u043b\u044f GAN. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u043e \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043e \u043d\u0438\u0445 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\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\/506032\/\"> https:\/\/habr.com\/ru\/post\/506032\/<\/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\/506032\/\">\u0414\u043b\u044f \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0440\u0435\u0434\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0441\u0442\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439-\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (GAN) \u043f\u043e\u0440\u0430\u0436\u0430\u0435\u0442 \u0438 \u0434\u0430\u0451\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/436088\/\">\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f<\/a> \u0438 \u0434\u0430\u0436\u0435 <a href=\"https:\/\/thispersondoesnotexist.com\/\">\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e<\/a> \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430.<br \/>  \u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f. \u0417\u0434\u0435\u0441\u044c \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u043e\u0434\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043e\u0441\u0442\u0440\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f\u0445 \u0438 \u0442\u0440\u044e\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.<\/p>\n<p>  \u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0432\u0437\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 <a href=\"https:\/\/www.tensorflow.org\/tutorials\/generative\/dcgan\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 tensorflow<\/a> \u0438 <a href=\"https:\/\/neurohive.io\/ru\/tutorial\/simple-gan-python-keras\/\">\u043a\u043e\u0434 \u043d\u0430 keras<\/a>. \u041e\u043d\u0438 \u043e\u0431\u0430 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u043d\u043e \u043a\u0430\u043a \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c \u043d\u0438\u0436\u0435, \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b. \u0418\u0434\u0435\u0438 \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/machinelearningmastery.com\/how-to-train-stable-generative-adversarial-networks\/\">Tips for GAN<\/a> \u0438 \u0438\u0437 <a href=\"https:\/\/arxiv.org\/pdf\/1511.06434.pdf\">\u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e GAN<\/a>.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e 2 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: numpy \u0438 tensorflow \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 GIF \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u043e \u0432 jupyter notebook.  <\/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-305095","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305095","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=305095"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305095\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}