@@ -880,6 +880,37 @@ def __init__(
880880 # value will be checked for compatibility with the placeholder.
881881 # If the key is a SparseTensor, the value should be a SparseTensorValue.
882882
883+ class GaussianNoiseLayer (Layer ):
884+ """
885+ The :class:`GaussianNoiseLayer` class is noise layer that adding noise with
886+ normal distribution to the activation.
887+
888+ Parameters
889+ ------------
890+ layer : a :class:`Layer` instance
891+ The `Layer` class feeding into this layer.
892+ sigma : float
893+ Scale value of gaussian noise.
894+ name : a string or None
895+ An optional name to attach to this layer.
896+ """
897+ def __init__ (
898+ self ,
899+ layer = None ,
900+ sigma = 0.1 ,
901+ name = 'gaussian_noise_layer' ,
902+ ):
903+ Layer .__init__ (self , name = name )
904+ self .inputs = layer .outputs
905+ print (" tensorlayer:Instantiate GaussianNoiseLayer %s: keep: %f" % (self .name , keep ))
906+ with tf .variable_scope (name ) as vs :
907+ noise = np .random .normal (0.0 , sigma , tf .to_int64 (input_layer ).get_shape ())
908+ self .inputs = self .inputs + noise
909+ self .all_layers = list (layer .all_layers )
910+ self .all_params = list (layer .all_params )
911+ self .all_drop = dict (layer .all_drop )
912+
913+
883914class DropconnectDenseLayer (Layer ):
884915 """
885916 The :class:`DropconnectDenseLayer` class is ``DenseLayer`` with DropConnect
@@ -3742,27 +3773,7 @@ def __init__(
37423773 self .all_layers .extend ( [self .outputs ] )
37433774 self .all_params .extend ( [W , b ] )
37443775
3745- # noise
3746- class GaussianNoiseLayer (Layer ):
3747- """
3748- Waiting for contribution
3749- """
3750- def __init__ (
3751- self ,
3752- layer = None ,
3753- sigma = 0.1 ,
3754- name = 'gaussian_noise_layer' ,
3755- ):
3756- Layer .__init__ (self , name = name )
3757- self .inputs = layer .outputs
3758- print (" tensorlayer:Instantiate GaussianNoiseLayer %s: keep: %f" % (self .name , keep ))
3759- print (" Waiting for contribution" )
3760- with tf .variable_scope (name ) as vs :
3761- noisy = np .random .normal (0.0 , sigma , tf .to_int64 (input_layer ).get_shape ())
3762- self .inputs = self .inputs + noisy
3763- self .all_layers = list (layer .all_layers )
3764- self .all_params = list (layer .all_params )
3765- self .all_drop = dict (layer .all_drop )
3776+
37663777
37673778
37683779
0 commit comments