Skip to content

Commit e7c6e84

Browse files
committed
update the docs
1 parent 5c3b350 commit e7c6e84

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

docs/create_your_own_brick.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ of :class:`.Brick` for a precise description of the life-cycle of a brick):
5757

5858
* :meth:`.Brick.__init__`: you should pass by argument the attributes of your
5959
brick. It is also in this method that you should create the potential
60-
"children bricks" that belongs to your brick (in that case, you have to put
61-
the children bricks into ``self.children``). The initialization of the
60+
"children bricks" that belongs to your brick (in that case, you have to pass
61+
the children bricks to ``super().__init__``). The initialization of the
6262
attributes can be lazy as described later in the tutorial.
6363
* :meth:`apply`: you need to implement a method that actually
6464
implements the operation of the brick, taking as arguments the inputs
@@ -210,10 +210,11 @@ specify the ``input_dim`` of ``brick2`` directly at its creation.
210210
>>> class ChainOfTwoFeedforward(Feedforward):
211211
... """Two sequential Feedforward bricks."""
212212
... def __init__(self, brick1, brick2, **kwargs):
213-
... super(Feedforward, self).__init__(**kwargs)
214213
... self.brick1 = brick1
215214
... self.brick2 = brick2
216-
... self.children = [self.brick1, self.brick2]
215+
... children = [self.brick1, self.brick2]
216+
... children += kwargs.get('children', [])
217+
... super(Feedforward, self).__init__(children=children, **kwargs)
217218
...
218219
... @property
219220
... def input_dim(self):
@@ -370,12 +371,14 @@ One can also create the brick using :class:`Linear` children bricks, which
370371
>>> class ParallelLinear2(Initializable):
371372
... def __init__(self, input_dim1, input_dim2, output_dim1, output_dim2,
372373
... **kwargs):
373-
... super(ParallelLinear2, self).__init__(**kwargs)
374374
... self.linear1 = Linear(input_dim1, output_dim1,
375375
... use_bias=False, **kwargs)
376376
... self.linear2 = Linear(input_dim2, output_dim2,
377377
... use_bias=False, **kwargs)
378-
... self.children = [self.linear1, self.linear2]
378+
... children = [self.linear1, self.linear2]
379+
... children += kwargs.get('children', [])
380+
... super(ParallelLinear2, self).__init__(children=children,
381+
... **kwargs)
379382
...
380383
... @application(inputs=['input1_', 'input2_'], outputs=['output1',
381384
... 'output2'])

0 commit comments

Comments
 (0)