from keras.layers import Dense, Input, Activation
input_size = 256
hidden_size = 32
output_size = 256
x = Input(shape=(input_size,))
# Encoder
h = Dense(hidden_size, activation='sigmoid')(x)
# Decoder
r = Dense(output_size, activation='sigmoid')(h)
autoencoder = Model(input=x, output=r)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(input_data, input_data, batch_size=128, epochs=10000, verbose=2)
from keras.layers import Dense, Input, Activation
input_size = 256
hidden_size = 32
output_size = 256
x = Input(shape=(input_size,))
# Encoder
hidden_1 = Dense(hidden_size, activation='sigmoid')(x)
h = Dense(code_size, activation='sigmoid')(hidden_1)
# Decoder
hidden_2 = Dense(hidden_size, activation='relu')(h)
r = Dense(input_size, activation='sigmoid')(hidden_2)
autoencoder = Model(input=x, output=r)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(input_data, input_data, batch_size=128, epochs=10000, verbose=2)
x = Input(shape=(28, 28,1))
# Encoder
conv1_1 = Conv2D(16, (3, 3), activation='relu', padding='same')(x)
pool1 = MaxPooling2D((2, 2), padding='same')(conv1_1)
conv1_2 = Conv2D(8, (3, 3), activation='relu', padding='same')(pool1)
pool2 = MaxPooling2D((2, 2), padding='same')(conv1_2)
conv1_3 = Conv2D(8, (3, 3), activation='relu', padding='same')(pool2)
h = MaxPooling2D((2, 2), padding='same')(conv1_3)
# Decoder
conv2_1 = Conv2D(8, (3, 3), activation='relu', padding='same')(h)
up1 = UpSampling2D((2, 2))(conv2_1)
conv2_2 = Conv2D(8, (3, 3), activation='relu', padding='same')(up1)
up2 = UpSampling2D((2, 2))(conv2_2)
conv2_3 = Conv2D(16, (3, 3), activation='relu')(up2)
up3 = UpSampling2D((2, 2))(conv2_3)
r = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(up3)
autoencoder = Model(input=x, output=r)
autoencoder.compile(optimizer='adam', loss='mse')
from keras.layers import Dense, Input, Activation
input_size = 256
hidden_size = 32
output_size = 256
x = Input(shape=(input_size,))
# Encoder
h = Dense(hidden_size, activation='sigmoid', activity_regularizer=regularizers.l1(10e-6))(x)
# Decoder
r = Dense(output_size, activation='sigmoid')(h)
autoencoder = Model(input=x, output=r)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(input_data, input_data, batch_size=128, epochs=10000, verbose=2)
也就是说用两个映射函数,将各种输入和输出全部都映射进来,然后变换以下,全部都将其搞定都行啦的理由与打算。全部都将其搞定都行啦的回事与打算。