Skip to content

Commit 8ec76b6

Browse files
committed
update TL to latest version
1 parent e0dc741 commit 8ec76b6

31 files changed

+5706
-1189
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ python main.py --mode=evaluate
6464
* [1] [Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network](https://arxiv.org/abs/1609.04802)
6565
* [2] [Is the deconvolution layer the same as a convolutional layer ?](https://arxiv.org/abs/1609.07009)
6666

67+
### Author
68+
- [zsdonghao](https://github.com/zsdonghao)
69+
6770
### License
6871

6972
- For academic and non-commercial use only.

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ def evaluate():
278278
# print(valid_lr_img.min(), valid_lr_img.max())
279279

280280
size = valid_lr_img.shape
281-
t_image = tf.placeholder('float32', [None, size[0], size[1], size[2]], name='input_image')
282-
# t_image = tf.placeholder('float32', [1, None, None, 3], name='input_image')
281+
# t_image = tf.placeholder('float32', [None, size[0], size[1], size[2]], name='input_image') # the old version of TL need to specify the image size
282+
t_image = tf.placeholder('float32', [1, None, None, 3], name='input_image')
283283

284284
net_g = SRGAN_g(t_image, is_train=False, reuse=False)
285285

tensorlayer/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
from . import prepro
2222
from . import nlp
2323
from . import rein
24+
from . import distributed
2425

2526
# alias
2627
act = activation
2728
vis = visualize
2829

29-
__version__ = "1.5.0"
30+
__version__ = "1.7.3"
3031

3132
global_flag = {}
3233
global_dict = {}

tensorlayer/activation.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#! /usr/bin/python
2-
# -*- coding: utf8 -*-
3-
4-
2+
# -*- coding: utf-8 -*-
53

64
import tensorflow as tf
75

@@ -13,7 +11,6 @@ def identity(x, name=None):
1311
x : a tensor input
1412
input(s)
1513
16-
1714
Returns
1815
--------
1916
A `Tensor` with the same type as `x`.
@@ -37,14 +34,13 @@ def ramp(x=None, v_min=0, v_max=1, name=None):
3734
name : a string or None
3835
An optional name to attach to this activation function.
3936
40-
4137
Returns
4238
--------
4339
A `Tensor` with the same type as `x`.
4440
"""
4541
return tf.clip_by_value(x, clip_value_min=v_min, clip_value_max=v_max, name=name)
4642

47-
def leaky_relu(x=None, alpha=0.1, name="LeakyReLU"):
43+
def leaky_relu(x=None, alpha=0.1, name="lrelu"):
4844
"""The LeakyReLU, Shortcut is ``lrelu``.
4945
5046
Modified version of ReLU, introducing a nonzero gradient for negative
@@ -67,16 +63,33 @@ def leaky_relu(x=None, alpha=0.1, name="LeakyReLU"):
6763
------------
6864
- `Rectifier Nonlinearities Improve Neural Network Acoustic Models, Maas et al. (2013) <http://web.stanford.edu/~awni/papers/relu_hybrid_icml2013_final.pdf>`_
6965
"""
70-
with tf.name_scope(name) as scope:
66+
# with tf.name_scope(name) as scope:
7167
# x = tf.nn.relu(x)
7268
# m_x = tf.nn.relu(-x)
7369
# x -= alpha * m_x
74-
x = tf.maximum(x, alpha * x)
70+
x = tf.maximum(x, alpha * x, name=name)
7571
return x
7672

7773
#Shortcut
7874
lrelu = leaky_relu
7975

76+
77+
def swish(x, name='swish'):
78+
"""The Swish function, see `Swish: a Self-Gated Activation Function <https://arxiv.org/abs/1710.05941>`_.
79+
80+
Parameters
81+
----------
82+
x : a tensor input
83+
input(s)
84+
85+
Returns
86+
--------
87+
A `Tensor` with the same type as `x`.
88+
"""
89+
with tf.name_scope(name) as scope:
90+
x = tf.nn.sigmoid(x) * x
91+
return x
92+
8093
def pixel_wise_softmax(output, name='pixel_wise_softmax'):
8194
"""Return the softmax outputs of images, every pixels have multiple label, the sum of a pixel is 1.
8295
Usually be used for image segmentation.

0 commit comments

Comments
 (0)