Skip to content

Commit e8fb7ec

Browse files
author
Timur Gilmullin
committed
#14: refactor networkwrapper.py - 2
1 parent f69d139 commit e8fb7ec

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

pybrain/supervised/evolino/networkwrapper.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,16 @@ def _getLastOutput(self):
167167
def _setLastOutput(self, output):
168168
self._out_layer.outputbuffer[self.offset - 1][:] = output
169169

170-
171170
# ======================================================== Genome related ===
172171

173-
174172
def _validateGenomeLayer(self, layer):
175173
""" Validates the type and state of a layer
176174
"""
177-
assert isinstance(layer, LSTMLayer)
178-
assert not layer.peepholes
175+
if not isinstance(layer, LSTMLayer):
176+
raise Exception("{} must have type of {}".format(str(layer), str(LSTMLayer)))
179177

178+
if layer.peepholes:
179+
raise Exception("{} must be False!".format(str(layer.peepholes)))
180180

181181
def getGenome(self):
182182
""" Returns the Genome of the network.
@@ -484,16 +484,18 @@ def getOutputLayer(self):
484484
assert len(self.network.outmodules) == 1
485485
return self.network.outmodules[0]
486486

487-
488-
489487
def getOutputConnection(self):
490488
""" Returns the input connection of the output layer. """
491489
if self._output_connection is None:
492490
outlayer = self.getOutputLayer()
493491
lastlayer = self.getLastHiddenLayer()
492+
494493
for c in self.getConnections():
495494
if c.outmod is outlayer:
496-
assert c.inmod is lastlayer
495+
496+
if c.inmod is not lastlayer:
497+
raise Exception("{} must have type of {}".format(str(c.inmod), str(lastlayer)))
498+
497499
self._output_connection = c
498500

499501
return self._output_connection

0 commit comments

Comments
 (0)