Skip to content

Commit e71f388

Browse files
committed
[layers] gaussian noise layer/ v1.3.0
1 parent 27011b5 commit e71f388

File tree

5 files changed

+56
-26
lines changed

5 files changed

+56
-26
lines changed

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
# built documents.
6868
#
6969
# The short X.Y version.
70-
version = '1.2.8'
70+
version = '1.3.0'
7171
# The full version, including alpha/beta/rc tags.
72-
release = '1.2.8'
72+
release = '1.3.0'
7373

7474
# The language for content autogenerated by Sphinx. Refer to documentation
7575
# for a list of supported languages.
@@ -143,7 +143,7 @@
143143
# The name for this set of Sphinx documents.
144144
# "<project> v<release> documentation" by default.
145145
#
146-
# html_title = 'TensorLayer v1.2.8'
146+
# html_title = 'TensorLayer v1.3.0'
147147

148148
# A shorter title for the navigation bar. Default is the same as html_title.
149149
#

docs/modules/layers.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,19 @@ Layer list
260260
get_variables_with_name
261261
set_name_reuse
262262
print_all_variables
263+
263264
Layer
265+
264266
InputLayer
265267
Word2vecEmbeddingInputlayer
266268
EmbeddingInputlayer
269+
267270
DenseLayer
268271
ReconLayer
269272
DropoutLayer
273+
GaussianNoiseLayer
270274
DropconnectDenseLayer
275+
271276
Conv1dLayer
272277
Conv2dLayer
273278
DeConv2dLayer
@@ -277,28 +282,38 @@ Layer list
277282
UpSampling2dLayer
278283
AtrousConv2dLayer
279284
LocalResponseNormLayer
285+
280286
Conv2d
281287
DeConv2d
282288
MaxPool2d
283289
MeanPool2d
290+
284291
BatchNormLayer
285292
LocalResponseNormLayer
293+
286294
RNNLayer
287295
BiRNNLayer
288296
advanced_indexing_op
289297
retrieve_seq_length_op
290298
retrieve_seq_length_op2
291299
DynamicRNNLayer
292300
BiDynamicRNNLayer
301+
293302
FlattenLayer
294303
ReshapeLayer
295304
LambdaLayer
305+
296306
ConcatLayer
297307
ElementwiseLayer
308+
298309
SlimNetsLayer
310+
299311
PReluLayer
312+
300313
MultiplexerLayer
314+
301315
EmbeddingAttentionSeq2seqWrapper
316+
302317
flatten_reshape
303318
clear_layers_name
304319
initialize_rnn_state
@@ -362,6 +377,10 @@ Dropout layer
362377
^^^^^^^^^^^^^^^^
363378
.. autoclass:: DropoutLayer
364379

380+
Gaussian noise layer
381+
^^^^^^^^^^^^^^^^^^^^^
382+
.. autoclass:: GaussianNoiseLayer
383+
365384
Dropconnect + Dense layer
366385
^^^^^^^^^^^^^^^^^^^^^^^^^^
367386
.. autoclass:: DropconnectDenseLayer

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name = "tensorlayer",
13-
version = "1.2.8",
13+
version = "1.3.0",
1414
include_package_data=True,
1515
author='TensorLayer Contributors',
1616
author_email='[email protected]',

tensorlayer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
from . import rein
2626

2727

28-
__version__ = "1.2.8"
28+
__version__ = "1.3.0"

tensorlayer/layers.py

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
883914
class 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

Comments
 (0)