def T9(): ''' Tests if multiple ANNRs can be created without affecting each other ''' A = np.random.rand(32, 4) Y = (A.sum(axis = 1) ** 2).reshape(-1, 1) m1 = ANNR([4], [('F', 4), ('AF', 'tanh'), ('F', 1)], maxIter = 16) m1.fit(A, Y) s1 = m1.score(A, Y) m2 = ANNR([4], [('F', 4), ('AF', 'tanh'), ('F', 1)], maxIter = 16) m2.fit(A, Y) s2 = m1.score(A, Y) if s1 != s2: return False return True
def T1(): ''' Tests basic functionality of ANNR ''' A = np.random.rand(32, 4) Y = np.random.rand(32, 1) a = ANNR([4], [('F', 4), ('AF', 'tanh'), ('F', 1)], maxIter = 16, name = 'mlpr1') a.fit(A, Y) S = a.score(A, Y) if np.isnan(S): return False YH = a.predict(A) if Y.shape != YH.shape: return False return True
def T7(): ''' Tests basic functionality of CNNC ''' A = np.random.rand(32, 9, 9, 3) Y = np.random.rand(32, 1) ws = [('C', [3, 3, 3, 4], [1, 1, 1, 1]), ('AF', 'relu'), ('P', [1, 4, 4, 1], [1, 2, 2, 1]), ('F', 16), ('AF', 'tanh'), ('F', 1)] a = ANNR([9, 9, 3], ws, maxIter = 12, name = "cnnr1") a.fit(A, Y) S = a.score(A, Y) if np.isnan(S): return False YH = a.predict(A) if Y.shape != YH.shape: return False return True