kerasでGANの一種であるpix2pixのモデルを実装しようと試みている初学者です。
あるサイトに掲載されているサンプルコードを参考にしています。
その中の、generator_unet_upsampling という関数を定義する部分に、
python
1first_conv = Conv2D(list_filters_num[0], (3,3), strides=(2,2), name='unet_conv2D_1', padding='same')(unet_input) 2 3list encoder = [first_conv]
という記載があり、その下には、
Python
1conv = conv_block_unet(list_encoder[-1], f, name, axis_num)
との記載があります。
しかし、この[first_conv]の中身がわからず、
list_encoder[-1]が何を示しているのか理解できていない現状です。
おそらく、各層における入力画像のことだと何となく考えていますが、
その点についてご教授いただけましたら大変助かります。
よろしくお願いいたします。
該当のソースコード
Python
1# 入力画像サイズ(256,256,3) 2 3def conv_block_unet(x, f, name, bn_axis, bn=True, strides=(2,2)): 4 x = LeakyReLU(0.2)(x) 5 x = Conv2D(f, (3,3), strides=strides, name=name, padding='same')(x) 6 if bn: x = BatchNormalization(axis=bn_axis)(x) 7 return x 8 9def generator_unet_upsampling(img_shape, disc_img_shape, model_name="generator_unet_upsampling"): 10 filters_num = 64 11 axis_num = -1 12 channels_num = img_shape[-1] 13 min_s = min(img_shape[:-1]) 14 15 unet_input = Input(shape=img_shape, name="unet_input") 16 17 conv_num = int(np.floor(np.log(min_s)/np.log(2))) 18 list_filters_num = [filters_num*min(8, (2**i)) for i in range(conv_num)] 19 20 # Encoder 21 first_conv = Conv2D(list_filters_num[0], (3,3), strides=(2,2), name='unet_conv2D_1', padding='same')(unet_input) 22 list_encoder = [first_conv] 23 for i, f in enumerate(list_filters_num[1:]): 24 name = 'unet_conv2D_' + str(i+2) 25 conv = conv_block_unet(list_encoder[-1], f, name, axis_num) 26 list_encoder.append(conv) 27
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/26 11:47