Skip to content

Commit e9e6c75

Browse files
committed
fix SOM Synapse bug
1 parent 59afc24 commit e9e6c75

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

ngclearn/components/synapses/competitive/SOMSynapse.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ def _gaussian_kernel(dist, sigma): ## Gaussian neighborhood function
1313
def _ricker_marr_kernel(dist, sigma): ## mexican hat neighborhood function
1414
# p = jnp.square(dist)
1515
# d = sigma * sigma * 2.
16-
#density = jnp.exp(-p/d) * (1. - 2./d * p)
16+
# density = jnp.exp(-p/d) * (1. - 2./d * p)
1717
# p = jnp.square(dist/ sigma)
1818
# density = (1. - p) * jnp.exp(p * -0.5)
1919
# #return jnp.prod(density, axis=1, keepdims=True) ## calc likelihood
2020
# return density
2121
gauss_density = _gaussian_kernel(dist, sigma)
2222
density = gauss_density * (1. - (jnp.power(dist, 2) / (sigma ** 2)))
23-
return density
23+
# NOTE: Since the mexican hat density can produce negative values,
24+
# we clip to 0 to avoid this.
25+
# Negative density mess up learning
26+
return jnp.maximum(density, 0.)
2427

2528
def _euclidean_dist(a, b): ## Euclidean (L2) distance
2629
delta = a - b

0 commit comments

Comments
 (0)