Skip to content

Commit 3b53142

Browse files
authored
Merge pull request tensorlayer#957 from tensorlayer/fix-docs
fix docs and numpy version
2 parents 4d6cb5a + 94d57ea commit 3b53142

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ To release a new version, please update the changelog as followed:
8484
### Deprecated
8585

8686
### Fixed
87+
- fix docs of models @zsdonghao #957
8788
- In `BatchNorm`, keep dimensions of mean and variance to suit `channels first` (PR #963)
8889

90+
8991
### Removed
9092

9193
### Security

requirements/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
imageio>=2.3,<2.5
2-
numpy>=1.14,<1.16
2+
numpy>=1.16,<1.17
33
progressbar2>=3.38,<3.39
44
requests==2.21.0
55
scikit-learn>=0.19,<0.21

tensorlayer/files/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ def load_npz(path='', name='model.npz'):
19581958
- `Saving dictionary using numpy <http://stackoverflow.com/questions/22315595/saving-dictionary-of-header-information-using-numpy-savez>`__
19591959
19601960
"""
1961-
d = np.load(os.path.join(path, name))
1961+
d = np.load(os.path.join(path, name), allow_pickle=True)
19621962
return d['params']
19631963

19641964

tensorlayer/models/core.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Model(object):
7575
>>> from tensorlayer.models import Model
7676
7777
Define static model
78+
7879
>>> class CustomModel(Model):
7980
>>> def __init__(self):
8081
>>> super(CustomModel, self).__init__()
@@ -97,6 +98,7 @@ class Model(object):
9798
>>> M_static = Model(inputs=ni, outputs=nn, name="mlp")
9899
99100
Get network information
101+
100102
>>> print(M_static)
101103
... Model(
102104
... (_inputlayer): Input(shape=[None, 784], name='_inputlayer')
@@ -106,21 +108,25 @@ class Model(object):
106108
... )
107109
108110
Forwarding through this network
111+
109112
>>> data = np.random.normal(size=[16, 784]).astype(np.float32)
110113
>>> outputs_d = M_dynamic(data)
111114
>>> outputs_s = M_static(data)
112115
113116
Save and load weights
117+
114118
>>> M_static.save_weights('./model_weights.h5')
115119
>>> M_static.load_weights('./model_weights.h5')
116120
117121
Save and load the model
122+
118123
>>> M_static.save('./model.h5')
119124
>>> M = Model.load('./model.h5')
120125
121126
Convert model to layer
127+
122128
>>> M_layer = M_static.as_layer()
123-
129+
124130
"""
125131

126132
@property
@@ -251,7 +257,7 @@ def __call__(self, inputs, is_train=None, **kwargs):
251257
If 'is_train' == False, this network is set as evaluation mode
252258
kwargs :
253259
For other keyword-only arguments.
254-
260+
255261
"""
256262

257263
self._check_mode(is_train)
@@ -694,7 +700,7 @@ def save(self, filepath, save_weights=True):
694700
>>> net = tl.models.vgg16()
695701
>>> net.save('./model.h5', save_weights=True)
696702
>>> new_net = Model.load('./model.h5', load_weights=True)
697-
703+
698704
"""
699705
# TODO: support saving LambdaLayer that includes parametric self defined function with outside variables
700706
if self.outputs is None:

0 commit comments

Comments
 (0)