Skip to content

Commit

Permalink
polish nn.Sequential attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
LDYang694 committed Jun 5, 2024
1 parent b1f18f0 commit 8d26bb8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/jittor/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,15 @@ def __len__(self):

def named_children(self,):
return list(self.layers.items())

def __setattr__(self, key, value) -> None:
if isinstance(key, str) and key.isdigit():
if int(key)<len(self.layers):
self.add_module(key, value)
else:
super().__setattr__(key, value)
else:
super().__setattr__(key, value)


def __getattr__(self, key):
Expand Down

0 comments on commit 8d26bb8

Please sign in to comment.