Skip to content

Commit

Permalink
Fix accuracy of circular convolution.
Browse files Browse the repository at this point in the history
The previous choice of intercept and eval point distribution was not
sufficiently validated. The choice in this commit performs better
and over a wider set of parameters.
  • Loading branch information
jgosmann committed Jun 13, 2017
1 parent fa97be9 commit 36d0acf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Release History
(`#35 <https://github.com/nengo/nengo/pull/35>`_,
`#32 <https://github.com/nengo/nengo/issues/32>`_,
`#34 <https://github.com/nengo/nengo/issues/34>`_)
- Improved accuracy by fixing choice of evaluation point and intercept
distributions.
(`#39 <https://github.com/nengo/nengo_spa/pull/39>`_)


0.1.1 (May 19, 2017)
Expand Down
15 changes: 6 additions & 9 deletions nengo_spa/networks/circularconvolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def transform_in(dims, align, invert):
tr[i] = row.real if i % 4 == 0 or i % 4 == 3 else row.imag

remove_imag_rows(tr)
tr /= np.sqrt(dims)
return tr.reshape((-1, dims))


Expand All @@ -67,6 +66,9 @@ def transform_out(dims):

tr = tr.reshape(4*dims2, dims)
remove_imag_rows(tr)
# IDFT has a 1/D scaling factor
tr /= dims

return tr.T


Expand Down Expand Up @@ -193,14 +195,9 @@ def CircularConvolution(n_neurons, dimensions, invert_a=False, invert_b=False,
with net:
net.input_a = nengo.Node(size_in=dimensions, label="input_a")
net.input_b = nengo.Node(size_in=dimensions, label="input_b")
with nengo.Config(nengo.Ensemble) as cfg:
cfg[nengo.Ensemble].eval_points = nengo.dists.CosineSimilarity(
2 * dimensions + 2)
cfg[nengo.Ensemble].intercepts = nengo.dists.CosineSimilarity(
2 * dimensions + 2)
net.product = Product(
n_neurons, tr_out.shape[1],
input_magnitude=input_magnitude / np.sqrt(2.))
net.product = Product(
n_neurons, tr_out.shape[1],
input_magnitude=2 * input_magnitude / np.sqrt(2.))
net.output = nengo.Node(size_in=dimensions, label="output")

nengo.Connection(
Expand Down

0 comments on commit 36d0acf

Please sign in to comment.