kerasのチュートリアルを元に畳み込みAEを記述しています.
2点気になっていることがあるので教えてください.
質問1
畳み込みAEを作成しているのですが,Dropoutの位置があっているのかわかりません.他にもDropoutを適用できる層はあるのでしょうか?
そして,畳み込み層の数はどのように決めればよいのでしょうか?
input_img = Input(shape=(28, 28, 1)) # adapt this if using `channels_first` image data format x = Conv2D(32, (3, 3), padding='same')(input_img) x = BatchNormalization()(x) x = Activation('relu')(x) x = MaxPooling2D((2, 2), padding='same')(x) x = Dropout(0.5)(x) x = Conv2D(32, (3, 3), padding='same')(x) x = BatchNormalization()(x) x = Activation('relu')(x) encoded = MaxPooling2D((2, 2), padding='same')(x) # at this point the representation is (7, 7, 32) x = Conv2D(32, (3, 3), padding='same')(encoded) x = BatchNormalization()(x) x = Activation('relu')(x) x = UpSampling2D((2, 2))(x) x = Conv2D(32, (3, 3), padding='same')(x) x = BatchNormalization()(x) x = Activation('relu')(x) x = UpSampling2D((2, 2))(x) decoded = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(x) autoencoder = Model(input_img, decoded) autoencoder.compile(optimizer='adam', loss='mean_squared_error')
質問2
kerasのコードを丸写ししただけなのですが,下記のコードはガウシアンノイズの付加と,白色化を行っているとの認識であっていますか?
英語で見る限りではそうだと思うのですが,noise_factorを0.5に固定しているところを見ると,自信がありません.
#データの読み込み (x_train, _), (x_test, _) = mnist.load_data() # (60000, 28, 28) x_train = x_train.astype('float32') / 255. x_test = x_test.astype('float32') / 255. x_train = np.reshape(x_train, (len(x_train), 28, 28, 1)) # adapt this if using `channels_first` image data format x_test = np.reshape(x_test, (len(x_test), 28, 28, 1)) # adapt this if using `channels_first` image data format #apply a gaussian noise matrix and clip the images between 0 and 1? noise_factor = 0.5 x_train_noisy = x_train + noise_factor * np.random.normal(loc=0.0, scale=1.0, size=x_train.shape) x_test_noisy = x_test + noise_factor * np.random.normal(loc=0.0, scale=1.0, size=x_test.shape) x_train_noisy = np.clip(x_train_noisy, 0., 1.) x_test_noisy = np.clip(x_test_noisy, 0., 1.)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/28 09:53
2019/07/28 12:19
2019/07/30 03:28
2019/08/06 08:45