Skip to content

Commit 26d7b40

Browse files
committed
add __all__ to all files
1 parent f58a08c commit 26d7b40

File tree

11 files changed

+219
-37
lines changed

11 files changed

+219
-37
lines changed

docs/modules/distributed.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Check this `minst example <https://github.com/zsdonghao/tensorlayer/blob/master/
1313
TaskSpecDef
1414
TaskSpec
1515
DistributedSession
16+
StopAtTimeHook
17+
LoadCheckpoint
1618

1719

1820
Distributed training

tensorlayer/activation.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33

44
import tensorflow as tf
55

6+
__all__ = [
7+
'identity',
8+
'ramp',
9+
'leaky_relu',
10+
'swish',
11+
'pixel_wise_softmax',
12+
'linear',
13+
'lrelu',
14+
]
15+
616

717
def identity(x):
818
"""The identity activation function.

tensorlayer/cost.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
# -*- coding: utf-8 -*-
22

33
import logging
4-
54
import tensorflow as tf
65

6+
__all__ = [
7+
'cross_entropy',
8+
'sigmoid_cross_entropy',
9+
'binary_cross_entropy',
10+
'mean_squared_error',
11+
'normalized_mean_square_error',
12+
'absolute_difference_error',
13+
'dice_coe',
14+
'dice_hard_coe',
15+
'iou_coe',
16+
'cross_entropy_seq',
17+
'cross_entropy_seq_with_mask',
18+
'cosine_similarity',
19+
'li_regularizer',
20+
'lo_regularizer',
21+
'maxnorm_regularizer',
22+
'maxnorm_o_regularizer',
23+
'maxnorm_i_regularizer',
24+
]
25+
726

827
def cross_entropy(output, target, name=None):
928
"""Softmax cross-entropy operation, returns the TensorFlow expression of cross-entropy for two distributions, it implements

tensorlayer/distributed.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#! /usr/bin/python
22
# -*- coding: utf-8 -*-
33

4-
import json
5-
import os
6-
import time
7-
4+
import json, os, time
85
import tensorflow as tf
96
from tensorflow.python.training import session_run_hook
107

8+
__all__ = ['TaskSpecDef', 'TaskSpec', 'DistributedSession', 'StopAtTimeHook', 'LoadCheckpoint']
9+
1110

1211
class TaskSpecDef(object):
1312
"""Specification for a distributed task.

tensorlayer/files.py

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,49 @@
4848
from . import _logging as logging
4949
from . import nlp, utils, visualize
5050

51+
__all__ = [
52+
'load_mnist_dataset',
53+
'load_fashion_mnist_dataset',
54+
'load_cifar10_dataset',
55+
'load_ptb_dataset',
56+
'load_matt_mahoney_text8_dataset',
57+
'load_imdb_dataset',
58+
'load_nietzsche_dataset',
59+
'load_wmt_en_fr_dataset',
60+
'load_flickr25k_dataset',
61+
'load_flickr1M_dataset',
62+
'load_cyclegan_dataset',
63+
'download_file_from_google_drive',
64+
'load_celebA_dataset',
65+
'load_voc_dataset',
66+
'save_npz',
67+
'load_npz',
68+
'assign_params',
69+
'load_and_assign_npz',
70+
'save_npz_dict',
71+
'load_and_assign_npz_dict',
72+
'save_ckpt',
73+
'load_ckpt',
74+
'save_any_to_npy',
75+
'load_npy_to_any',
76+
'file_exists',
77+
'folder_exists',
78+
'del_file',
79+
'del_folder',
80+
'read_file',
81+
'load_file_list',
82+
'load_folder_list',
83+
'exists_or_mkdir',
84+
'maybe_download_and_extract',
85+
'natural_keys',
86+
'npz_to_W_pdf',
87+
]
88+
5189

5290
## Load dataset functions
5391
def load_mnist_dataset(shape=(-1, 784), path='data'):
5492
"""Load the original mnist.
55-
93+
5694
Automatically download MNIST dataset and return the training, validation and test set with 50000, 10000 and 10000 digit images respectively.
5795
5896
Parameters
@@ -61,7 +99,7 @@ def load_mnist_dataset(shape=(-1, 784), path='data'):
6199
The shape of digit images (the default is (-1, 784), alternatively (-1, 28, 28, 1)).
62100
path : str
63101
The path that the data is downloaded to.
64-
102+
65103
Returns
66104
-------
67105
X_train, y_train, X_val, y_val, X_test, y_test: tuple
@@ -77,7 +115,7 @@ def load_mnist_dataset(shape=(-1, 784), path='data'):
77115

78116
def load_fashion_mnist_dataset(shape=(-1, 784), path='data'):
79117
"""Load the fashion mnist.
80-
118+
81119
Automatically download fashion-MNIST dataset and return the training, validation and test set with 50000, 10000 and 10000 fashion images respectively, `examples <http://marubon-ds.blogspot.co.uk/2017/09/fashion-mnist-exploring.html>`__.
82120
83121
Parameters
@@ -86,7 +124,7 @@ def load_fashion_mnist_dataset(shape=(-1, 784), path='data'):
86124
The shape of digit images (the default is (-1, 784), alternatively (-1, 28, 28, 1)).
87125
path : str
88126
The path that the data is downloaded to.
89-
127+
90128
Returns
91129
-------
92130
X_train, y_train, X_val, y_val, X_test, y_test: tuple
@@ -102,7 +140,7 @@ def load_fashion_mnist_dataset(shape=(-1, 784), path='data'):
102140

103141
def _load_mnist_dataset(shape, path, name='mnist', url='http://yann.lecun.com/exdb/mnist/'):
104142
"""A generic function to load mnist-like dataset.
105-
143+
106144
Parameters:
107145
----------
108146
shape : tuple

tensorlayer/iterate.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
import numpy as np
55
from six.moves import xrange
66

7+
__all__ = [
8+
'minibatches',
9+
'seq_minibatches',
10+
'seq_minibatches2',
11+
'ptb_iterator',
12+
]
13+
714

815
def minibatches(inputs=None, targets=None, batch_size=None, shuffle=False):
916
"""Generate a generator that input a group of example in numpy.array and

tensorlayer/nlp.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
# -*- coding: utf-8 -*-
22

3-
import collections
4-
import os
5-
import random
6-
import re
7-
# Metric
8-
import subprocess
9-
import tempfile
10-
import warnings
11-
3+
import collections, os, random
4+
import re, subprocess, tempfile, warnings
125
import numpy as np
136
import tensorflow as tf
147
from six.moves import urllib, xrange
158
from tensorflow.python.platform import gfile
16-
179
from . import _logging as logging
1810

11+
__all__ = [
12+
'generate_skip_gram_batch',
13+
'sample',
14+
'sample_top',
15+
'SimpleVocabulary',
16+
'Vocabulary',
17+
'process_sentence',
18+
'create_vocab',
19+
'simple_read_words',
20+
'read_words',
21+
'read_analogies_file',
22+
'build_vocab',
23+
'build_reverse_dictionary',
24+
'build_words_dataset',
25+
'words_to_word_ids',
26+
'word_ids_to_words',
27+
'save_vocab',
28+
'basic_tokenizer',
29+
'create_vocabulary',
30+
'initialize_vocabulary',
31+
'sentence_to_token_ids',
32+
'data_to_token_ids',
33+
'moses_multi_bleu',
34+
]
35+
1936

2037
def generate_skip_gram_batch(data, batch_size, num_skips, skip_window, data_index=0):
2138
"""Generate a training batch for the Skip-Gram model.

tensorlayer/prepro.py

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# -*- coding: utf-8 -*-
22

3-
import threading
4-
import time
5-
3+
import threading, time, scipy, skimage
64
import numpy as np
7-
import scipy
85
import scipy.ndimage as ndi
9-
import skimage
106
# import tensorlayer as tl
117
from scipy import linalg
128
from scipy.ndimage.filters import gaussian_filter
@@ -17,6 +13,74 @@
1713
# linalg https://docs.scipy.org/doc/scipy/reference/linalg.html
1814
# ndimage https://docs.scipy.org/doc/scipy/reference/ndimage.html
1915

16+
__all__ = [
17+
'threading_data',
18+
'rotation',
19+
'rotation_multi',
20+
'crop',
21+
'crop_multi',
22+
'flip_axis',
23+
'flip_axis_multi',
24+
'shift',
25+
'shift_multi',
26+
'shear',
27+
'shear_multi',
28+
'shear2',
29+
'shear_multi2',
30+
'swirl',
31+
'swirl_multi',
32+
'elastic_transform',
33+
'elastic_transform_multi',
34+
'zoom',
35+
'zoom_multi',
36+
'brightness',
37+
'brightness_multi',
38+
'illumination',
39+
'rgb_to_hsv',
40+
'hsv_to_rgb',
41+
'adjust_hue',
42+
'imresize',
43+
'pixel_value_scale',
44+
'samplewise_norm',
45+
'featurewise_norm',
46+
'get_zca_whitening_principal_components_img',
47+
'zca_whitening',
48+
'channel_shift',
49+
'channel_shift_multi',
50+
'drop',
51+
'transform_matrix_offset_center',
52+
'apply_transform',
53+
'projective_transform_by_points',
54+
'array_to_img',
55+
'find_contours',
56+
'pt2map',
57+
'binary_dilation',
58+
'dilation',
59+
'binary_erosion',
60+
'erosion',
61+
'obj_box_coords_rescale',
62+
'obj_box_coord_rescale',
63+
'obj_box_coord_scale_to_pixelunit',
64+
'obj_box_coord_centroid_to_upleft_butright',
65+
'obj_box_coord_upleft_butright_to_centroid',
66+
'obj_box_coord_centroid_to_upleft',
67+
'obj_box_coord_upleft_to_centroid',
68+
'parse_darknet_ann_str_to_list',
69+
'parse_darknet_ann_list_to_cls_box',
70+
'obj_box_left_right_flip',
71+
'obj_box_imresize',
72+
'obj_box_crop',
73+
'obj_box_shift',
74+
'obj_box_zoom',
75+
'pad_sequences',
76+
'remove_pad_sequences',
77+
'process_sequences',
78+
'sequences_add_start_id',
79+
'sequences_add_end_id',
80+
'sequences_add_end_id_after_pad',
81+
'sequences_get_mask',
82+
]
83+
2084

2185
def threading_data(data=None, fn=None, thread_count=None, **kwargs):
2286
"""Process a batch of data by given function by threading.
@@ -748,8 +812,6 @@ def swirl_multi(x,
748812

749813

750814
# elastic_transform
751-
752-
753815
def elastic_transform(x, alpha, sigma, mode="constant", cval=0, is_random=False):
754816
"""Elastic transformation for image as described in `[Simard2003] <http://deeplearning.cs.cmu.edu/pdfs/Simard.pdf>`__.
755817

tensorlayer/rein.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import tensorflow as tf
66
from six.moves import xrange
77

8+
__all__ = [
9+
'discount_episode_rewards',
10+
'cross_entropy_reward_loss',
11+
'log_weight',
12+
'choice_action_by_probs',
13+
]
14+
815

916
def discount_episode_rewards(rewards=None, gamma=0.99, mode=0):
1017
"""Take 1D float array of rewards and compute discounted rewards for an

tensorlayer/utils.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
# -*- coding: utf-8 -*-
2-
import os
3-
import random
4-
import subprocess
5-
import sys
6-
import time
2+
import os, random, subprocess, sys, time
73
from sys import exit as _exit
84
from sys import platform as _platform
9-
105
import numpy as np
116
import tensorflow as tf
12-
137
import tensorlayer as tl
14-
158
from . import _logging as logging
169
from . import iterate
1710

11+
__all__ = [
12+
'fit',
13+
'test',
14+
'predict',
15+
'evaluation',
16+
'dict_to_one',
17+
'flatten_list',
18+
'class_balancing_oversample',
19+
'get_random_int',
20+
'list_string_to_dict',
21+
'exit_tensorflow',
22+
'open_tensorboard',
23+
'clear_all_placeholder_variables',
24+
'set_gpu_fraction',
25+
]
26+
1827

1928
def fit(sess,
2029
network,

0 commit comments

Comments
 (0)