Skip to content

Commit f69d139

Browse files
author
Timur Gilmullin
committed
#14: refactor networkwrapper.py
1 parent 12af9df commit f69d139

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

pybrain/supervised/evolino/networkwrapper.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
__author__ = 'Michael Isik'
2-
1+
# -*- coding: utf-8 -*-
32

43
from pybrain.structure.networks.network import Network
54
from pybrain.structure.modules.lstm import LSTMLayer
@@ -10,6 +9,8 @@
109

1110
from numpy import zeros, array, append
1211

12+
__author__ = 'Michael Isik'
13+
1314

1415
class EvolinoNetwork(Module):
1516
def __init__(self, indim, outdim, hiddim=6):
@@ -41,13 +42,19 @@ def __init__(self, indim, outdim, hiddim=6):
4142
def reset(self):
4243
self._network.reset()
4344

44-
4545
def _washout(self, input, target, first_idx=None, last_idx=None):
46-
assert self.indim == len(input[0])
47-
assert self.outdim == len(target[0])
48-
assert len(input) == len(target)
46+
if self.indim != len(input[0]):
47+
raise Exception("{} must be equal to {}".format(str(self.indim), str(len(input[0]))))
48+
49+
if self.outdim != len(target[0]):
50+
raise Exception("{} must be equal to {}".format(str(self.outdim), str(len(target[0]))))
51+
52+
if len(input) != len(target):
53+
raise Exception("{} must be equal to {}".format(str(len(input)), str(len(target))))
54+
55+
if first_idx is None:
56+
first_idx = 0
4957

50-
if first_idx is None: first_idx = 0
5158
if last_idx is None: last_idx = len(target) - 1
5259
raw_outputs = []
5360
for i in xrange(first_idx, last_idx + 1):

0 commit comments

Comments
 (0)