Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
szha committed Oct 21, 2017
1 parent 6851edc commit 062893f
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions python/mxnet/gluon/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def __init__(self, prefix=None, params=None):
self._name = self._prefix[:-1] if self._prefix.endswith('_') else self._prefix
self._scope = _BlockScope(self)
self._children = []
self._collected_params = None

def __repr__(self):
s = '{name}(\n{modstr}\n)'
Expand All @@ -189,7 +188,6 @@ def __setattr__(self, name, value):
type1=type(existing),
type2=type(value)))
if isinstance(existing, Block):
self._unfreeze_children()
for i, c in enumerate(self._children):
if c is existing:
self._children[i] = value
Expand All @@ -203,17 +201,6 @@ def __setattr__(self, name, value):
def _alias(self):
return self.__class__.__name__.lower()

def _is_children_frozen(self):
return isinstance(self._children, tuple)

def _freeze_children(self):
if not self._is_children_frozen():
self._children = tuple(self._children)

def _unfreeze_children(self):
if self._is_children_frozen():
self._children = list(self._children)

@property
def prefix(self):
"""Prefix of this :py:class:`Block`."""
Expand Down Expand Up @@ -242,15 +229,10 @@ def params(self):
def collect_params(self):
"""Returns a :py:class:`ParameterDict` containing this :py:class:`Block` and all of its
children's Parameters."""
if self._is_children_frozen() and self._collected_params is not None:
return self._collected_params

self._freeze_children()
ret = ParameterDict(self._params.prefix)
ret.update(self.params)
for cld in self._children:
ret.update(cld.collect_params())
self._collected_params = ret
return ret

def save_params(self, filename):
Expand Down Expand Up @@ -282,7 +264,6 @@ def load_params(self, filename, ctx, allow_missing=False,
def register_child(self, block):
"""Registers block as a child of self. :py:class:`Block` s assigned to self as
attributes will be registered automatically."""
self._unfreeze_children()
self._children.append(block)

def initialize(self, init=initializer.Uniform(), ctx=None, verbose=False):
Expand Down

0 comments on commit 062893f

Please sign in to comment.