Skip to content

Commit

Permalink
Update cvae_keras.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bojone authored Jun 10, 2019
1 parent 620b2d7 commit 68972b5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cvae_keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
latent_dim = 2 # 隐变量取2维只是为了方便后面画图
intermediate_dim = 256
epochs = 100
epsilon_std = 1.0
num_classes = 10


# 加载MNIST数据集
(x_train, y_train_), (x_test, y_test_) = mnist.load_data()
x_train = x_train.astype('float32') / 255.
Expand All @@ -52,8 +52,7 @@
# 重参数技巧
def sampling(args):
z_mean, z_log_var = args
epsilon = K.random_normal(shape=(K.shape(z_mean)[0], latent_dim), mean=0.,
stddev=epsilon_std)
epsilon = K.random_normal(shape=K.shape(z_mean))
return z_mean + K.exp(z_log_var / 2) * epsilon

# 重参数层,相当于给输入加入噪声
Expand Down

0 comments on commit 68972b5

Please sign in to comment.