def create_decoder(latent, bn_flag): l1 = Conv2d([latent], [l_dims[2][0]], l_dims[1][0], kernel_size=l_dims[2][1:3], name="dec1", random_state=random_state) bn_l1 = BatchNorm2d(l1, bn_flag, name="bn_dec3") r_l1 = ReLU(bn_l1) l2 = ConvTranspose2d([r_l1], [l_dims[1][0]], l_dims[0][0], kernel_size=l_dims[1][1:3], name="dec2", strides=l_dims[1][-1], border_mode=bpad, random_state=random_state) bn_l2 = BatchNorm2d(l2, bn_flag, name="bn_dec2") r_l2 = ReLU(bn_l2) l3 = ConvTranspose2d([r_l2], [l_dims[0][0]], 1, kernel_size=l_dims[0][1:3], name="dec3", strides=l_dims[0][-1], border_mode=bpad, random_state=random_state) s_l3 = Sigmoid(l3) return s_l3
def create_decoder(latent, bn_flag): l1 = Conv2d([latent], [l_dims[3][0]], l_dims[2][0], kernel_size=l_dims[3][1:3], name="dec1", random_state=random_state) bn_l1 = BatchNorm2d(l1, bn_flag, name="bn_dec1") r_l1 = ReLU(bn_l1) l2 = ConvTranspose2d([r_l1], [l_dims[2][0]], l_dims[1][0], kernel_size=l_dims[2][1:3], name="dec2", strides=l_dims[2][-1], border_mode=dbpad, random_state=random_state) bn_l2 = BatchNorm2d(l2, bn_flag, name="bn_dec2") r_l2 = ReLU(bn_l2) l3 = ConvTranspose2d([r_l2], [l_dims[1][0]], l_dims[0][0], kernel_size=l_dims[1][1:3], name="dec3", strides=l_dims[1][-1], border_mode=dbpad, random_state=random_state) bn_l3 = BatchNorm2d(l3, bn_flag, name="bn_dec3") r_l3 = ReLU(bn_l3) # hack it and do depth to space in_chan = l_dims[0][0] out_chan = 257 kernel_sz = [l_dims[0][1], l_dims[0][2]] kernel_sz[1] = 1 l4 = ConvTranspose2d([r_l3], [in_chan], out_chan, kernel_size=kernel_sz, name="dec4", strides=l_dims[0][-1], border_mode=dbpad, random_state=random_state) s_l4 = Sigmoid(l4) s_l4 = tf.transpose(s_l4, (0, 1, 3, 2)) return s_l4
def create_decoder(latent, bn_flag): l1 = Conv2d([latent], [l_dims[-1][0]], l_dims[-2][0], kernel_size=l_dims[-1][1:3], name="dec1", random_state=random_state) bn_l1 = BatchNorm2d(l1, bn_flag, name="bn_dec1") r_l1 = ReLU(bn_l1) l2 = ConvTranspose2d([r_l1], [l_dims[-2][0]], l_dims[-3][0], kernel_size=l_dims[-2][1:3], name="dec2", strides=l_dims[-2][-1], border_mode=dbpad, random_state=random_state) bn_l2 = BatchNorm2d(l2, bn_flag, name="bn_dec2") r_l2 = ReLU(bn_l2) l3 = ConvTranspose2d([r_l2], [l_dims[-3][0]], 4 * n_out, kernel_size=l_dims[-3][1:3], name="dec3", strides=l_dims[-3][-1], border_mode=dbpad, random_state=random_state) return tf.reshape(l3, (-1, 1, 48, 4, n_out))
def create_decoder(latent, bn_flag): l1 = Conv2d([latent], [l_dims[-1][0]], l_dims[-2][0], kernel_size=l_dims[-1][1:3], name="dec1", random_state=random_state) bn_l1 = BatchNorm2d(l1, bn_flag, name="bn_dec1") r_l1 = ReLU(bn_l1) l2 = ConvTranspose2d([r_l1], [l_dims[-2][0]], l_dims[-3][0], kernel_size=l_dims[-2][1:3], name="dec2", strides=l_dims[-2][-1], border_mode=dbpad, random_state=random_state) bn_l2 = BatchNorm2d(l2, bn_flag, name="bn_dec2") r_l2 = ReLU(bn_l2) l3 = ConvTranspose2d([r_l2], [l_dims[-3][0]], l_dims[-4][0], kernel_size=l_dims[-3][1:3], name="dec3", strides=l_dims[-3][-1], border_mode=dbpad, random_state=random_state) bn_l3 = BatchNorm2d(l3, bn_flag, name="bn_dec3") r_l3 = ReLU(bn_l3) l4 = ConvTranspose2d([r_l3], [l_dims[-4][0]], l_dims[-5][0], kernel_size=l_dims[-4][1:3], name="dec4", strides=l_dims[-4][-1], border_mode=dbpad, random_state=random_state) bn_l4 = BatchNorm2d(l4, bn_flag, name="bn_dec4") r_l4 = ReLU(bn_l4) l5 = ConvTranspose2d([r_l4], [l_dims[-5][0]], dmol_proj, kernel_size=l_dims[-5][1:3], name="dec5", strides=l_dims[-5][-1], border_mode=dbpad, random_state=random_state) l5_mix, l5_means, l5_lin_scales = DiscreteMixtureOfLogistics( [l5], [dmol_proj], n_components=n_components, name="d_out", random_state=random_state) return l5_mix, l5_means, l5_lin_scales
def create_decoder(latent, bn_flag): l1 = Conv2d([latent], [l_dims[-1][0]], l_dims[-2][0], kernel_size=l_dims[-1][1:3], name="dec1", random_state=random_state) bn_l1 = BatchNorm2d(l1, bn_flag, name="bn_dec1") r_l1 = ReLU(bn_l1) l2 = ConvTranspose2d([r_l1], [l_dims[-2][0]], l_dims[-3][0], kernel_size=l_dims[-2][1:3], name="dec2", strides=l_dims[-2][-1], border_mode=dbpad, random_state=random_state) bn_l2 = BatchNorm2d(l2, bn_flag, name="bn_dec2") r_l2 = ReLU(bn_l2) l3 = ConvTranspose2d([r_l2], [l_dims[-3][0]], l_dims[-4][0], kernel_size=l_dims[-3][1:3], name="dec3", strides=l_dims[-3][-1], border_mode=dbpad, random_state=random_state) bn_l3 = BatchNorm2d(l3, bn_flag, name="bn_dec3") r_l3 = ReLU(bn_l3) l4 = ConvTranspose2d([r_l3], [l_dims[-4][0]], l_dims[-5][0], kernel_size=l_dims[-4][1:3], name="dec4", strides=l_dims[-4][-1], border_mode=dbpad, random_state=random_state) bn_l4 = BatchNorm2d(l4, bn_flag, name="bn_dec4") r_l4 = ReLU(bn_l4) l5 = ConvTranspose2d([r_l4], [l_dims[-5][0]], 1, kernel_size=l_dims[-5][1:3], name="dec5", strides=l_dims[-5][-1], border_mode=dbpad, random_state=random_state) #s_l5 = Sigmoid(l5) t_l5 = Tanh(l5) return t_l5