Skip to content

[fix bug] (1) add (non)trainable_weights in Layerlist (2) remove redu… #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ To release a new version, please update the changelog as followed:
- Set allow_pickle=True in np.load() (#PR 1021)
- Remove `private_method` decorator (#PR 1025)
- Copy original model's `trainable_weights` and `nontrainable_weights` when initializing `ModelLayer` (#PR 1026)
- Copy original model's `trainable_weights` and `nontrainable_weights` when initializing `LayerList` (#PR 1029)
- remove redundant parts in `model.all_layers` (#PR 1029)

### Removed

Expand All @@ -119,7 +121,7 @@ To release a new version, please update the changelog as followed:

- @zsdonghao
- @ChrisWu1997: #1010 #1015 #1025
- @warshallrho: #1017 #1021 #1026
- @warshallrho: #1017 #1021 #1026 #1029
- @ArnoldLIULJ: #1023
- @JingqingZ: #1023

Expand Down
2 changes: 2 additions & 0 deletions tensorlayer/layers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ def __init__(self, layers, name=None):

is_built = True
for layer in self.layers:
self._trainable_weights.extend(layer.trainable_weights)
self._nontrainable_weights.extend(layer.nontrainable_weights)
if layer._built is False:
is_built = False
if layer._built and layer.all_weights is not None:
Expand Down
5 changes: 5 additions & 0 deletions tensorlayer/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,12 @@ def all_layers(self):
attr_list.remove("all_weights")
attr_list.remove("trainable_weights")
attr_list.remove("nontrainable_weights")
attr_list.remove("_all_weights")
attr_list.remove("_trainable_weights")
attr_list.remove("_nontrainable_weights")
attr_list.remove("all_layers")
attr_list.remove("_all_layers")
attr_list.remove("n_weights")
for idx, attr in enumerate(attr_list):
try:
if isinstance(getattr(self, attr), Layer):
Expand Down