You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2017/07/31 22:58:24 UTC
[incubator-mxnet] branch master updated: add getitem to container
layers (#7265)
This is an automated email from the ASF dual-hosted git repository.
jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new c521fa5 add getitem to container layers (#7265)
c521fa5 is described below
commit c521fa5d12d88f3b8ad0917ed8ad66093d9631b9
Author: Sheng Zha <sz...@users.noreply.github.com>
AuthorDate: Mon Jul 31 15:58:22 2017 -0700
add getitem to container layers (#7265)
* add getitem to container layers
* add __len__
* move __len__ to container classes
---
python/mxnet/gluon/nn/basic_layers.py | 12 ++++++++++++
python/mxnet/gluon/rnn/rnn_cell.py | 6 ++++++
2 files changed, 18 insertions(+)
diff --git a/python/mxnet/gluon/nn/basic_layers.py b/python/mxnet/gluon/nn/basic_layers.py
index 063deb4..afe2df7 100644
--- a/python/mxnet/gluon/nn/basic_layers.py
+++ b/python/mxnet/gluon/nn/basic_layers.py
@@ -38,6 +38,12 @@ class Sequential(Block):
return s.format(name=self.__class__.__name__,
modstr=modstr)
+ def __getitem__(self, i):
+ return self._children[i]
+
+ def __len__(self):
+ return len(self._children)
+
class HybridSequential(HybridBlock):
"""Stacks `HybridBlock`s sequentially.
@@ -71,6 +77,12 @@ class HybridSequential(HybridBlock):
return s.format(name=self.__class__.__name__,
modstr=modstr)
+ def __getitem__(self, i):
+ return self._children[i]
+
+ def __len__(self):
+ return len(self._children)
+
class Dense(HybridBlock):
"""Just your regular densely-connected NN layer.
diff --git a/python/mxnet/gluon/rnn/rnn_cell.py b/python/mxnet/gluon/rnn/rnn_cell.py
index 7315a27..e6ce65b 100644
--- a/python/mxnet/gluon/rnn/rnn_cell.py
+++ b/python/mxnet/gluon/rnn/rnn_cell.py
@@ -545,6 +545,12 @@ class SequentialRNNCell(RecurrentCell):
return inputs, next_states
+ def __getitem__(self, i):
+ return self._children[i]
+
+ def __len__(self):
+ return len(self._children)
+
def hybrid_forward(self, *args, **kwargs):
raise NotImplementedError
--
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].