Skip to content

Commit

Permalink
update TL to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
zsdonghao committed Jan 15, 2018
1 parent e0dc741 commit 8ec76b6
Show file tree
Hide file tree
Showing 31 changed files with 5,706 additions and 1,189 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ python main.py --mode=evaluate
* [1] [Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network](https://arxiv.org/abs/1609.04802)
* [2] [Is the deconvolution layer the same as a convolutional layer ?](https://arxiv.org/abs/1609.07009)

### Author
- [zsdonghao](https://github.com/zsdonghao)

### License

- For academic and non-commercial use only.
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ def evaluate():
# print(valid_lr_img.min(), valid_lr_img.max())

size = valid_lr_img.shape
t_image = tf.placeholder('float32', [None, size[0], size[1], size[2]], name='input_image')
# t_image = tf.placeholder('float32', [1, None, None, 3], name='input_image')
# 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
t_image = tf.placeholder('float32', [1, None, None, 3], name='input_image')

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

Expand Down
3 changes: 2 additions & 1 deletion tensorlayer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
from . import prepro
from . import nlp
from . import rein
from . import distributed

# alias
act = activation
vis = visualize

__version__ = "1.5.0"
__version__ = "1.7.3"

global_flag = {}
global_dict = {}
29 changes: 21 additions & 8 deletions tensorlayer/activation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#! /usr/bin/python
# -*- coding: utf8 -*-


# -*- coding: utf-8 -*-

import tensorflow as tf

Expand All @@ -13,7 +11,6 @@ def identity(x, name=None):
x : a tensor input
input(s)
Returns
--------
A `Tensor` with the same type as `x`.
Expand All @@ -37,14 +34,13 @@ def ramp(x=None, v_min=0, v_max=1, name=None):
name : a string or None
An optional name to attach to this activation function.
Returns
--------
A `Tensor` with the same type as `x`.
"""
return tf.clip_by_value(x, clip_value_min=v_min, clip_value_max=v_max, name=name)

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

#Shortcut
lrelu = leaky_relu


def swish(x, name='swish'):
"""The Swish function, see `Swish: a Self-Gated Activation Function <https://arxiv.org/abs/1710.05941>`_.
Parameters
----------
x : a tensor input
input(s)
Returns
--------
A `Tensor` with the same type as `x`.
"""
with tf.name_scope(name) as scope:
x = tf.nn.sigmoid(x) * x
return x

def pixel_wise_softmax(output, name='pixel_wise_softmax'):
"""Return the softmax outputs of images, every pixels have multiple label, the sum of a pixel is 1.
Usually be used for image segmentation.
Expand Down
Loading

0 comments on commit 8ec76b6

Please sign in to comment.