代码拉取完成,页面将自动刷新
同步操作将从 wanghairui-harry/DESOM 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""
Implementation of the Deep Embedded Self-Organizing Map model
Autoencoder helper function
@author Florent Forest
@version 2.0
"""
from keras.models import Model
from keras.layers import Input, Dense
def mlp_autoencoder(encoder_dims, act='relu', init='glorot_uniform'):
"""
Fully connected symmetric autoencoder model.
# Arguments
encoder_dims: list of number of units in each layer of encoder. encoder_dims[0] is input dim, encoder_dims[-1] is units in hidden layer (latent dim).
The decoder is symmetric with encoder, so number of layers of the AE is 2*len(encoder_dims)-1
act: activation of AE intermediate layers, not applied to Input, Hidden and Output layers
init: initialization of AE layers
# Return
(ae_model, encoder_model, decoder_model): AE, encoder and decoder models
"""
n_stacks = len(encoder_dims) - 1
# Input
x = Input(shape=(encoder_dims[0],), name='input')
# Internal layers in encoder
encoded = x
for i in range(n_stacks-1):
encoded = Dense(encoder_dims[i + 1], activation=act, kernel_initializer=init, name='encoder_%d' % i)(encoded)
# Hidden layer (latent space)
encoded = Dense(encoder_dims[-1], kernel_initializer=init, name='encoder_%d' % (n_stacks - 1))(encoded) # hidden layer, latent representation is extracted from here
# Internal layers in decoder
decoded = encoded
for i in range(n_stacks-1, 0, -1):
decoded = Dense(encoder_dims[i], activation=act, kernel_initializer=init, name='decoder_%d' % i)(decoded)
# Output
decoded = Dense(encoder_dims[0], kernel_initializer=init, name='decoder_0')(decoded)
# AE model
autoencoder = Model(inputs=x, outputs=decoded, name='AE')
# Encoder model
encoder = Model(inputs=x, outputs=encoded, name='encoder')
# Create input for decoder model
encoded_input = Input(shape=(encoder_dims[-1],))
# Internal layers in decoder
decoded = encoded_input
for i in range(n_stacks-1, -1, -1):
decoded = autoencoder.get_layer('decoder_%d' % i)(decoded)
# Decoder model
decoder = Model(inputs=encoded_input, outputs=decoded, name='decoder')
return autoencoder, encoder, decoder
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。