예제 #1
0
def test_convolution(rng):
    a = SemanticPointer(64, rng=rng)
    b = SemanticPointer(64, rng=rng)
    identity = SemanticPointer(np.eye(64)[0])

    c = a.copy()
    c *= b

    ans = np.fft.ifft(np.fft.fft(a.v) * np.fft.fft(b.v)).real

    assert np.allclose((a * b).v, ans)
    assert np.allclose(a.convolve(b).v, ans)
    assert np.allclose(c.v, ans)
    assert np.allclose((a * identity).v, a.v)
    assert (a * b * ~b).compare(a) > 0.65
예제 #2
0
def test_convolution(rng):
    a = SemanticPointer(64, rng=rng)
    b = SemanticPointer(64, rng=rng)
    identity = SemanticPointer(np.eye(64)[0])

    c = a.copy()
    c *= b

    ans = np.fft.ifft(np.fft.fft(a.v) * np.fft.fft(b.v)).real

    assert np.allclose((a * b).v, ans)
    assert np.allclose(a.convolve(b).v, ans)
    assert np.allclose(c.v, ans)
    assert np.allclose((a * identity).v, a.v)
    assert (a * b * ~b).compare(a) > 0.65
예제 #3
0
파일: test_pointer.py 프로젝트: Ocode/nengo
def test_convolution():
    rng = np.random.RandomState(3)
    a = SemanticPointer(50, rng=rng)
    b = SemanticPointer(50, rng=rng)
    identity = SemanticPointer(np.eye(50)[0])

    c = a.copy()
    c *= b

    ans = np.fft.ifft(np.fft.fft(a.v) * np.fft.fft(b.v)).real

    assert np.allclose((a * b).v, ans)
    assert np.allclose(a.convolve(b).v, ans)
    assert np.allclose(c.v, ans)
    assert np.allclose((a * identity).v, a.v)
    assert (a * b * ~b).compare(a) > 0.7
예제 #4
0
def test_convolution():
    rng = np.random.RandomState(3)
    a = SemanticPointer(50, rng=rng)
    b = SemanticPointer(50, rng=rng)
    identity = SemanticPointer(np.eye(50)[0])

    c = a.copy()
    c *= b

    ans = np.fft.ifft(np.fft.fft(a.v) * np.fft.fft(b.v)).real

    assert np.allclose((a * b).v, ans)
    assert np.allclose(a.convolve(b).v, ans)
    assert np.allclose(c.v, ans)
    assert np.allclose((a * identity).v, a.v)
    assert (a * b * ~b).compare(a) > 0.7