예제 #1
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)
예제 #2
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)
예제 #3
0
파일: test_link.py 프로젝트: imclab/dana
def test_distance_sparse_2():
    """ Check link distance computation, sparse """

    G1 = dana.zeros((5, 5))
    G2 = dana.group(np.random.random((5, 5)))
    G1.connect(G2, np.ones((1, 1)), 'I-', sparse=True, shared=False)
    G1.dV = 'I'
    G1.compute()
    assert np_almost_equal(G1.V, 1 - G2.V)
예제 #4
0
파일: test_link.py 프로젝트: imclab/dana
def test_weighted_sum_sparse_2():
    """ Check link weighted sum computation, sparse """

    G1 = dana.zeros((3, 3))
    G2 = dana.ones((3, 3))
    G1.connect(G2, np.ones((3, 3)), 'I', sparse=True, shared=False)
    G1.dV = 'I-V'
    G1.compute()
    assert np_almost_equal(G1.V, np.array([[4, 6, 4], [6, 9, 6], [4, 6, 4]]))
예제 #5
0
파일: test_link.py 프로젝트: imclab/dana
def test_weighted_sum_sparse_1():
    """ Check link weighted sum computation, sparse """

    G1 = dana.zeros((5, ))
    G2 = dana.ones((5, ))
    G1.connect(G2, np.ones((5, )), 'I', sparse=True, shared=False)
    G1.dV = 'I-V'
    G1.compute()
    assert np_almost_equal(G1.V, np.array([3, 4, 5, 4, 3]))
예제 #6
0
파일: test_link.py 프로젝트: B-Rich/dana
def test_distance_sparse_2():
    """ Check link distance computation, sparse """

    G1 = dana.zeros((5,5))
    G2 = dana.group(np.random.random((5,5)))
    G1.connect(G2, np.ones((1,1)), 'I-', sparse=True, shared=False)
    G1.dV = 'I'
    G1.compute()
    assert np_almost_equal(G1.V,1-G2.V)
예제 #7
0
파일: test_link.py 프로젝트: B-Rich/dana
def test_weighted_sum_sparse_1():
    """ Check link weighted sum computation, sparse """

    G1 = dana.zeros((5,))
    G2 = dana.ones((5,))
    G1.connect(G2,np.ones((5,)), 'I', sparse=True, shared=False)
    G1.dV = 'I-V'
    G1.compute()
    assert np_almost_equal(G1.V, np.array([3,4,5,4,3]))
예제 #8
0
파일: test_link.py 프로젝트: imclab/dana
def test_weighted_sum_sparse_3():
    """ Check link weighted sum computation, sparse, masked """

    G1 = dana.zeros((3, 3))
    G2 = dana.ones((3, 3))
    G1.connect(G2, np.ones((3, 3)), 'I', sparse=True, shared=False)
    G2.mask[1, 1] = False
    G1.dV = 'I-V'
    G1.compute()
    assert np_almost_equal(G1.V, np.array([[3, 5, 3], [5, 8, 5], [3, 5, 3]]))
예제 #9
0
파일: test_link.py 프로젝트: B-Rich/dana
def test_weighted_sum_sparse_2():
    """ Check link weighted sum computation, sparse """

    G1 = dana.zeros((3,3))
    G2 = dana.ones((3,3))
    G1.connect(G2,np.ones((3,3)), 'I', sparse=True, shared=False)
    G1.dV = 'I-V'
    G1.compute()
    assert np_almost_equal(G1.V, np.array([[4,6,4],
                                           [6,9,6],
                                           [4,6,4]]))
예제 #10
0
파일: test_link.py 프로젝트: B-Rich/dana
def test_weighted_sum_sparse_3():
    """ Check link weighted sum computation, sparse, masked """

    G1 = dana.zeros((3,3))
    G2 = dana.ones((3,3))
    G1.connect(G2,np.ones((3,3)), 'I', sparse=True, shared=False)
    G2.mask[1,1] = False
    G1.dV = 'I-V'
    G1.compute()
    assert np_almost_equal(G1.V, np.array([[3,5,3],
                                           [5,8,5],
                                           [3,5,3]]))
예제 #11
0
"""
Created on Wed Oct  3 10:55:40 2012

@author: rohan
"""

import dana, numpy


n = 60
dt = 0.1
alpha = 10.0
tau = 1.0
h = 0.0

I = dana.zeros((n, n))
U = dana.zeros((n, n))

U.connect(I.V, numpy.ones((1, 1)), "I", sparse=True)

K = 1.25 * dana.gaussian((2 * n + 1, 2 * n + 1), 0.1) - 0.7 * dana.gaussian((2 * n + 1, 2 * n + 1), 1)

U.connect(U.V, K, "L", shared=True)

U.dV = U.dV = "-V + maximum(V+dt/tau*(-V+(L/(N*N)*10*10+I+h)/alpha),0)"

I.V = dana.gaussian((N, N), 0.2, (0.5, 0.5))
I.V += dana.gaussian((N, N), 0.2, (-0.5, -0.5))
I.V += (2 * numpy.random.random((N, N)) - 1) * 0.05

for i in range(250):