decoder = models.Sequential(name='conditional_decoder') decoder.add(layers.Dense(4 * 4 * 128, input_shape=(2+10,), name='expand')) decoder.add(layers.Reshape((4, 4, 128), name='reshape2')) decoder.add(layers.Conv2DTranspose(64, (3, 3), strides=2, padding='same', activation='relu', name='conv_transpose1')) # (8, 8, 64) decoder.add(layers.Conv2DTranspose(32, (3, 3), strides=2, padding='same', activation='relu', name='conv_transpose2')) # (16, 16, 32) decoder.add(layers.Conv2DTranspose(1, (3, 3), strides=2, padding='same', activation='sigmoid', name='conv_transpose3')) # (32, 32, 1) decoder.add(layers.Flatten(name='flatten')) model_input = tf.keras.Input(shape=(32*32+10,)) model_output = layers.Concatenate(name='prediction_with_mean_log_var')( [encoder(model_input[:, :32*32]), # Receive mean and log_var decoder(tf.concat( (sampler(encoder(model_input[:, :32*32])), model_input[:, 32*32:]), axis=1) # Provide label to the decoder ) # Receive reconstructed image ] ) ラベル値 サンプラーの出力値