예제 #1
0
 def test_5(self):
     n = 10
     Z = np.random.random(n)
     K = np.random.random(n)
     Z1 = DenseConnection(Z,Z,K,toric=True).output()
     Z2 = SharedConnection(Z,Z,K,toric=True,fft=False).output()
     Z3 = SharedConnection(Z,Z,K,toric=True,fft=True).output()
     Z4 = convolve(Z, K[::-1], mode='wrap')
     assert np_equal(Z1,Z4)
     assert np_equal(Z2,Z4)
     assert np_equal(Z3,Z4)
예제 #2
0
 def test_7(self):
     n = 9
     Z = np.random.random(n)
     K = np.random.random(n//2)
     Z1 = DenseConnection(Z,Z,K,toric=False).output()
     Z2 = SharedConnection(Z,Z,K,toric=False,fft=False).output()
     Z3 = SharedConnection(Z,Z,K,toric=False,fft=True).output()
     Z4 = convolve(Z, K[::-1], mode='constant')
     assert np_equal(Z1,Z4)
     assert np_equal(Z2,Z4)
     assert np_equal(Z3,Z4)
예제 #3
0
 def test_1(self):
     n = 9
     Z = np.random.random((n,n))
     K = np.random.random((n//2,n//2))
     Z1 = DenseConnection(Z,Z,K,toric=True).output()
     Z2 = SparseConnection(Z,Z,K,toric=True).output()
     Z3 = SharedConnection(Z,Z,K,toric=True,fft=False).output()
     Z4 = SharedConnection(Z,Z,K,toric=True,fft=True).output()
     Z5 = convolve(Z, K[::-1,::-1], mode='wrap')
     assert np_equal(Z1,Z5)
     assert np_equal(Z2,Z5)
     assert np_equal(Z3,Z5)
     assert np_equal(Z4,Z5)
예제 #4
0
 def test_12(self):
     n = 10
     Z = np.random.random((n,n))
     K = np.random.random((2*n,2*n))
     Z1 = DenseConnection(Z,Z,K,toric=False).output()
     Z2 = SparseConnection(Z,Z,K,toric=False).output()
     Z3 = SharedConnection(Z,Z,K,toric=False,fft=False).output()
     Z4 = SharedConnection(Z,Z,K,toric=False,fft=True).output()
     Z5 = convolve(Z, K[::-1,::-1], mode='constant')
     assert np_equal(Z1,Z5)
     assert np_equal(Z2,Z5)
     assert np_equal(Z3,Z5)
     assert np_equal(Z4,Z5)
예제 #5
0
 def test_6(self):
     n = 10
     Z = np.random.random((n,n))
     K = np.random.random((2*n,2*n))
     Z1 = DenseConnection(Z,Z,K,toric=True).output()
     Z2 = SparseConnection(Z,Z,K,toric=True).output()
     Z3 = SharedConnection(Z,Z,K,toric=True,fft=False).output()
     Z4 = SharedConnection(Z,Z,K,toric=True,fft=True).output()
     K_ = K[5:15,5:15]
     Z5 = convolve(Z, K_[::-1,::-1], mode='wrap')
     assert np_equal(Z1,Z5)
     assert np_equal(Z2,Z5)
     assert np_equal(Z3,Z5)
     assert np_equal(Z4,Z5)
예제 #6
0
 def test_7(self):
     assert np_equal( Connection(ones((3,3)), ones((3,3)), array([[1, 1, 1],
                                                                  [1,NaN,1],
                                                                  [1, 1, 1]]),fft=True).output(),
                      array([[3,5,3],
                             [5,8,5],
                             [3,5,3]]))
예제 #7
0
 def test_5(self):
     assert np_equal( Connection(ones((3,3)), ones((5,5)), ones((3,3)),fft=True).output(),
                      array([[4,4,6,4,4],
                             [4,4,6,4,4],
                             [6,6,9,6,6],
                             [4,4,6,4,4],
                             [4,4,6,4,4]]))
예제 #8
0
 def test_7(self):
     assert np_equal( Connection(ones((3,3)), ones((3,3)), array([[1, 1, 1],
                                                                  [1,NaN,1],
                                                                  [1, 1, 1]])).output(),
                      array([[3,5,3],
                             [5,8,5],
                             [3,5,3]]))
예제 #9
0
 def test_4(self):
     src = np.ones((3, ))
     dst = zeros((3, ), 'V=I; I')
     kernel = np.ones(1)
     C = DenseConnection(src, dst('I'), kernel, equation='dW/dt = post.I')
     dst.run(dt=0.1)
     assert np_equal(C.weights, np.identity(3) * 1.1)
예제 #10
0
파일: group.py 프로젝트: B-Rich/dana
 def test_1(self):
     G = Group(5, 'V = I; I')
     Z = np.ones(5)
     DenseConnection(Z, G('I'), 1)
     DenseConnection(Z, G('I'), 2)
     G.run()
     assert np_equal(3*np.ones(5),G('V'))
예제 #11
0
파일: group.py 프로젝트: imclab/dana
 def test_1(self):
     G = Group(5, 'V = I; I')
     Z = np.ones(5)
     DenseConnection(Z, G('I'), 1)
     DenseConnection(Z, G('I'), 2)
     G.run()
     assert np_equal(3 * np.ones(5), G('V'))
예제 #12
0
파일: group.py 프로젝트: B-Rich/dana
 def test_mask_shape_2(self):
     mask = np.ones((3,3))
     mask[1,1] = 0
     self.Z.mask = mask
     self.Z[...] = 1
     self.Z.setup()
     assert np_equal(self.Z.f0,mask)
예제 #13
0
 def test_5(self):
     assert np_equal( Connection(ones((3,3)), ones((5,5)), ones((3,3))).output(),
                      array([[4,4,6,4,4],
                             [4,4,6,4,4],
                             [6,6,9,6,6],
                             [4,4,6,4,4],
                             [4,4,6,4,4]]))
예제 #14
0
파일: group.py 프로젝트: imclab/dana
 def test_mask_shape_2(self):
     mask = np.ones((3, 3))
     mask[1, 1] = 0
     self.Z.mask = mask
     self.Z[...] = 1
     self.Z.setup()
     assert np_equal(self.Z.f0, mask)
예제 #15
0
 def test_1(self):
     kernel = np.ones(1)
     C = SparseConnection(np.ones(3),
                          np.ones(3),
                          kernel,
                          equation='dW/dt = 1')
     C.evaluate(dt=.1)
     assert np_equal(C.weights, np.identity(3) * 1.1)
예제 #16
0
 def test_2(self):
     kernel = np.ones(3) * np.NaN
     C = SparseConnection(np.ones(3),
                          np.ones(3),
                          kernel,
                          equation='dW/dt = 1')
     C.evaluate(dt=.1)
     assert np_equal(C.weights, np.zeros((3, 3)))
예제 #17
0
 def test_11_ter(self):
     assert np_equal(
         Connection(ones((3, 3)),
                    ones((3, 3)),
                    ones((1, 20)),
                    toric=True,
                    fft=False).output(),
         ones((3, 3)) * 3)
예제 #18
0
파일: learning.py 프로젝트: B-Rich/dana
 def test_4(self):
     src = np.ones((3,))
     dst = zeros((3,) , 'V=I; I')
     kernel = np.ones(1)
     C = DenseConnection(src, dst('I'), kernel,
                          equation = 'dW/dt = post.I')
     dst.run(dt=0.1)
     assert np_equal(C.weights, np.identity(3)*1.1)
예제 #19
0
 def test_15(self):
     Z = ones((5, 5))
     K = arange(5 * 5).reshape((5, 5))
     C = Connection(Z, Z, K)
     assert np_equal(
         C[4, 4],
         array([[NaN, NaN, NaN, NaN, NaN], [NaN, NaN, NaN, NaN, NaN],
                [NaN, NaN, 0, 1, 2], [NaN, NaN, 5, 6, 7],
                [NaN, NaN, 10, 11, 12]]))
예제 #20
0
 def test_14(self):
     Z = ones((5, 5))
     K = arange(5 * 5).reshape((5, 5))
     C = Connection(Z, Z, K)
     assert np_equal(
         C[4, 0],
         array([[NaN, NaN, NaN, NaN, NaN], [NaN, NaN, NaN, NaN, NaN],
                [2, 3, 4, NaN, NaN], [7, 8, 9, NaN, NaN],
                [12, 13, 14, NaN, NaN]]))
예제 #21
0
 def test_13(self):
     Z = ones((5, 5))
     K = arange(5 * 5).reshape((5, 5))
     C = Connection(Z, Z, K)
     assert np_equal(
         C[0, 4],
         array([[NaN, NaN, 10, 11, 12], [NaN, NaN, 15, 16, 17],
                [NaN, NaN, 20, 21, 22], [NaN, NaN, NaN, NaN, NaN],
                [NaN, NaN, NaN, NaN, NaN]]))
예제 #22
0
 def test_12(self):
     Z = ones((5, 5))
     K = arange(5 * 5).reshape((5, 5))
     C = Connection(Z, Z, K)
     assert np_equal(
         C[0, 0],
         array([[12, 13, 14, NaN, NaN], [17, 18, 19, NaN, NaN],
                [22, 23, 24, NaN, NaN], [NaN, NaN, NaN, NaN, NaN],
                [NaN, NaN, NaN, NaN, NaN]]))
예제 #23
0
파일: learning.py 프로젝트: B-Rich/dana
 def test_3(self):
     kernel = np.ones(3)
     kernel[1] = np.NaN
     C = SparseConnection(np.ones(3), np.ones(3), kernel,
                          equation = 'dW/dt = 1')
     C.evaluate(dt=0.1)
     assert np_equal(C.weights, np.array([[0,1,0],
                                          [1,0,1],
                                          [0,1,0]])*1.1)
예제 #24
0
 def test_15(self):
     Z = ones((5,5))
     K = arange(5*5).reshape((5,5))
     C = Connection(Z,Z,K)
     assert np_equal(C[4,4],
                     array([[NaN,NaN,NaN,NaN,NaN],
                            [NaN,NaN,NaN,NaN,NaN],
                            [NaN,NaN,  0,  1,  2],
                            [NaN,NaN,  5,  6,  7],
                            [NaN,NaN, 10, 11, 12]]))
예제 #25
0
 def test_14(self):
     Z = ones((5,5))
     K = arange(5*5).reshape((5,5))
     C = Connection(Z,Z,K)
     assert np_equal(C[4,0],
                     array([[NaN,NaN,NaN,NaN,NaN],
                            [NaN,NaN,NaN,NaN,NaN],
                            [  2,  3,  4,NaN,NaN],
                            [  7,  8,  9,NaN,NaN],
                            [ 12, 13, 14,NaN,NaN]]))
예제 #26
0
 def test_13(self):
     Z = ones((5,5))
     K = arange(5*5).reshape((5,5))
     C = Connection(Z,Z,K)
     assert np_equal(C[0,4],
                     array([[NaN,NaN,10, 11, 12],
                            [NaN,NaN,15, 16, 17],
                            [NaN,NaN,20, 21, 22],
                            [NaN,NaN,NaN,NaN,NaN],
                            [NaN,NaN,NaN,NaN,NaN]]))
예제 #27
0
 def test_3(self):
     kernel = np.ones(3)
     kernel[1] = np.NaN
     C = SparseConnection(np.ones(3),
                          np.ones(3),
                          kernel,
                          equation='dW/dt = 1')
     C.evaluate(dt=0.1)
     assert np_equal(C.weights,
                     np.array([[0, 1, 0], [1, 0, 1], [0, 1, 0]]) * 1.1)
예제 #28
0
 def test_12(self):
     Z = ones((5,5))
     K = arange(5*5).reshape((5,5))
     C = Connection(Z,Z,K)
     assert np_equal(C[0,0],
                     array([[12, 13, 14,NaN,NaN],
                            [17, 18, 19,NaN,NaN],
                            [22, 23, 24,NaN,NaN],
                            [NaN,NaN,NaN,NaN,NaN],
                            [NaN,NaN,NaN,NaN,NaN]]))
예제 #29
0
파일: network.py 프로젝트: B-Rich/dana
 def test_3(self):
     net = Network(Clock(0.0, 1.0, 0.001))
     src = Group((1,), 'dV/dt=1')
     src[...] = 1
     dst = Group((1,) , 'I')
     dst[...] = 0
     kernel = np.ones(1)
     C = DenseConnection(src('V'), dst('I'), kernel)
     net.append(src)
     net.append(dst)
     V,I=[],[]
     @net.clock.every(0.1,order=-1)
     def do(t):
         V.append(src['V'][0])
         I.append(dst['I'][0])
     net.run(time=1.0, dt=0.1)
     assert np_equal(np.array(V),
                     [1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0])
     assert np_equal(np.array(I),
                     [0.0,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9])
예제 #30
0
    def test_3(self):
        net = Network(Clock(0.0, 1.0, 0.001))
        src = Group((1, ), 'dV/dt=1')
        src[...] = 1
        dst = Group((1, ), 'I')
        dst[...] = 0
        kernel = np.ones(1)
        C = DenseConnection(src('V'), dst('I'), kernel)
        net.append(src)
        net.append(dst)
        V, I = [], []

        @net.clock.every(0.1, order=-1)
        def do(t):
            V.append(src['V'][0])
            I.append(dst['I'][0])

        net.run(time=1.0, dt=0.1)
        assert np_equal(
            np.array(V),
            [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0])
        assert np_equal(
            np.array(I),
            [0.0, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9])
예제 #31
0
 def test_11_bis(self):
     assert np_equal(Connection(ones((3,3)), ones((3,3)), ones((20,20)), toric=True).output(),
                     ones((3,3))*9)
예제 #32
0
 def test_10(self):
     C = Connection(ones((3,3)), ones((3,3)), ones((1,1)))
     assert np_equal(C[1,1], array([[NaN, NaN, NaN],
                                    [NaN,  1,  NaN],
                                    [NaN, NaN, NaN]]))
예제 #33
0
 def test_8(self):
     assert np_equal( Connection(ones((3,3)), ones((3,3)), ones((3,3))*NaN).output(),
                      zeros((3,3)) )
예제 #34
0
 def test_8(self):
     assert np_equal(
         Connection(ones((3, 3)), ones((3, 3)),
                    ones((3, 3)) * NaN).output(), zeros((3, 3)))
예제 #35
0
 def test_11_bis(self):
     assert np_equal(Connection(ones(3), ones(3), ones(20), toric=True).output(),
                     ones(3)*3)
예제 #36
0
 def test_11_bis(self):
     assert np_equal(
         Connection(ones((3, 3)), ones((3, 3)), ones((20, 20)),
                    toric=True).output(),
         ones((3, 3)) * 9)
예제 #37
0
 def test_16(self):
     Z = ones((5, 5))
     K = arange(5 * 5).reshape((5, 5))
     C = Connection(Z, Z, K)
     assert np_equal(C[2, 2], K)
예제 #38
0
 def test_3(self):
     assert np_equal(
         Connection(ones(5), ones(3), ones(1)).output(), ones(3))
예제 #39
0
 def test_3(self):
     assert np_equal( Connection(ones(5), ones(3), ones(1)).output(),
                      ones(3))
예제 #40
0
 def test_7(self):
     assert np_equal( Connection(ones(3), ones(3), array([1,NaN,1])).output(),
                      array([1,2,1]))
예제 #41
0
 def test_11_ter(self):
     assert np_equal(Connection(ones((3,3)), ones((3,3)), ones((1,20)), toric=True).output(),
                     ones((3,3))*3)
예제 #42
0
 def test_10(self):
     C = Connection(ones((3, 3)), ones((3, 3)), ones((1, 1)))
     assert np_equal(
         C[1, 1], array([[NaN, NaN, NaN], [NaN, 1, NaN], [NaN, NaN, NaN]]))
예제 #43
0
 def test_3(self):
     assert np_equal( Connection(ones((5,5)), ones((3,3)), ones((1,1))).output(),
                      ones((3,3)))
예제 #44
0
 def test_6(self):
     assert np_equal(
         Connection(ones(5), ones(3), ones(3)).output(), array([2, 3, 2]))
예제 #45
0
 def test_9(self):
     assert np_equal( Connection(ones(3), ones(3), ones((3,3))).output(),
                      3*ones(3))
예제 #46
0
 def test_16(self):
     Z = ones((5,5))
     K = arange(5*5).reshape((5,5))
     C = Connection(Z,Z,K)
     assert np_equal(C[2,2],K)
예제 #47
0
 def test_7(self):
     assert np_equal(
         Connection(ones(3), ones(3), array([1, NaN, 1])).output(),
         array([1, 2, 1]))
예제 #48
0
 def test_6(self):
     assert np_equal( Connection(ones(5), ones(3), ones(3)).output(),
                      array([2,3,2]))
예제 #49
0
 def test_8(self):
     assert np_equal(
         Connection(ones(3), ones(3), array([NaN, NaN, NaN])).output(),
         zeros(3))
예제 #50
0
 def test_8(self):
     assert np_equal( Connection(ones(3), ones(3), array([NaN,NaN,NaN])).output(),
                      zeros(3))
예제 #51
0
 def test_9(self):
     assert np_equal(
         Connection(ones(3), ones(3), ones((3, 3))).output(), 3 * ones(3))
예제 #52
0
 def test_10(self):
     C = Connection(ones(3), ones(3), ones(1))
     assert np_equal(C[0], array([1, NaN, NaN]))
     assert np_equal(C[1], array([NaN, 1, NaN]))
     assert np_equal(C[2], array([NaN, NaN, 1]))
예제 #53
0
 def test_10(self):
     C = Connection(ones(3), ones(3), ones(1))
     assert np_equal(C[0], array([1, NaN, NaN]))
     assert np_equal(C[1], array([NaN, 1, NaN]))
     assert np_equal(C[2], array([NaN, NaN, 1]))
예제 #54
0
 def test_12(self):
     Z = ones(5)
     K = arange(5)
     C = Connection(Z,Z,K)
     assert np_equal(C[0], array([2,3,4,NaN,NaN]))
예제 #55
0
 def test_11_bis(self):
     assert np_equal(
         Connection(ones(3), ones(3), ones(20), toric=True).output(),
         ones(3) * 3)