1. 模型简介
为了提高自编码器的泛化性能和鲁棒性,在输入的数据中,我们加入高斯白噪声,通过深度网络进行学习,以获取“无噪声”情况下的输出数据——有一点向去除噪声,实际上,最开始通过堆叠的自动编码器实现噪声去除。
2. 模型实现
(注意:模型和AE的区别就是,输入网络的数据是加噪声的数据,代价函数却采用的是无噪声数据进行计算)
# whilt gaussian noise Auto-Encoder
#
# Author: HSW
# Date: 2018-05-07
#
import tensorflow as tf
import numpy as np
def axvier_init(fan_in, fan_out, constant = 1):
''' Initial weights '''
low = -constant + np.sqrt(6.0 / (fan_in + fan_out))
high = constant + np.sqrt(6.0 / (fan_in + fan_out))
return tf.random_uniform((fan_in, fan_out), minval = low, maxval = high, dtype = tf.float32)
class NoiseAutoEncoder(object):
def __init__(self, AutoEncoder_Shape = (128, 256, 128), transfer_function = tf.nn.softplus, optimizer = tf.train.AdamOptimizer(), sigma = 0.1):
''' Constructor Funcion '''
self.sigma = sigma
self.LayerCnt = len(AutoEncoder_Shape)
self.AutoEncoder_Shape = AutoEncoder_Shape
self.transfer = transfer_function
self.weights = self.init_weights()
self.layers = self.init_layers()
self.total_loss = self.init_loss()
self.optimizer