File tree Expand file tree Collapse file tree
ngclearn/components/synapses/competitive Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,14 +13,17 @@ def _gaussian_kernel(dist, sigma): ## Gaussian neighborhood function
1313def _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
2528def _euclidean_dist (a , b ): ## Euclidean (L2) distance
2629 delta = a - b
You can’t perform that action at this time.
0 commit comments