我需要学习具有实际值(真实值)的自动编码器的知识

时间:2019-03-26 02:46:38

标签: keras autoencoder

当我使用R或Keras等实现可变自动编码器时,我会对输入的训练数据进行z归一化(当然是逐列的)。并且每个层的激活函数和超参数指定如下。

batch_size <- 1
original_dim <- 10
latent_dim <- 2L
intermediate_dim <- 5L
epochs <- 50L
epsilon_std <- 2
x <- layer_input(shape = c(original_dim))
h <- layer_dense(x, intermediate_dim, activation = "linear")
z_mean <- layer_dense(h, latent_dim)
z_log_var <- layer_dense(h, latent_dim)

sampling <- function(arg){
  z_mean <- arg[, 1:(latent_dim)]
  z_log_var <- arg[, (latent_dim + 1):(2 * latent_dim)]

  epsilon <- k_random_normal(
    shape = c(k_shape(z_mean)[[1]]), 
    mean=0.,
    stddev=epsilon_std
  )

  z_mean + k_exp(z_log_var/2)*epsilon
}

z <- layer_concatenate(list(z_mean, z_log_var)) %>% 
  layer_lambda(sampling)

decoder_h <- layer_dense(units = intermediate_dim, activation = "linear")
decoder_mean <- layer_dense(units = original_dim, activation = "linear")
h_decoded <- decoder_h(z)
x_decoded_mean <- decoder_mean(h_decoded)

vae <- keras_model(x, x_decoded_mean)
optimizer_sgd(lr = 0.01, momentum = 0.01, decay = 0.001)
vae %>% compile(optimizer = "sgd", loss = 'mean_squared_error', metrics = c('mse'))
vae %>% fit(
  x_train, x_train, 
  shuffle = TRUE, 
  epochs = 200, 
  batch_size = 1, 
  validation_data = list(x_test, x_test),
  verbose = 1
)

在训练阶段之后,甚至所有超参数都只有“ looks” [-1,1]的输出值。

enter image description here

所以我的问题是 1.如果我想训练自己的对手,我应该对我的输入数据进行0-1或-1-1归一化吗?而不是z归一化?我认为,就我而言,z归一化是适当的,因为我的数据不是Image而是实值数据 2.对于使用实值数据训练自动编码器有什么想法吗?

非常感谢您

0 个答案:

没有答案