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)
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)
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)
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]]))
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]))
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)
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]))
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]]))
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]]))
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]]))
""" 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):