Skip to content

Commit 969bb1b

Browse files
author
Alexander Ororbia
committed
minor clean-up of som-syn
1 parent 4c355a8 commit 969bb1b

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

ngclearn/components/synapses/competitive/SOMSynapse.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,14 @@
77

88
def _gaussian_kernel(dist, sigma): ## Gaussian neighborhood function
99
density = jnp.exp(-jnp.power(dist, 2) / (2 * (sigma ** 2))) # n_units x 1
10-
#return jnp.prod(density, axis=1, keepdims=True) ## calc likelihood
1110
return density
1211

1312
def _ricker_marr_kernel(dist, sigma): ## mexican hat neighborhood function
14-
# p = jnp.square(dist)
15-
# d = sigma * sigma * 2.
16-
# density = jnp.exp(-p/d) * (1. - 2./d * p)
17-
# p = jnp.square(dist/ sigma)
18-
# density = (1. - p) * jnp.exp(p * -0.5)
19-
# #return jnp.prod(density, axis=1, keepdims=True) ## calc likelihood
20-
# return density
13+
## can reform Ricker-Marr in terms of a function of a Gaussian density
2114
gauss_density = _gaussian_kernel(dist, sigma)
2215
density = gauss_density * (1. - (jnp.power(dist, 2) / (sigma ** 2)))
2316
# NOTE: Since the mexican hat density can produce negative values,
24-
# we clip to 0 to avoid this.
25-
# Negative density mess up learning
17+
# we clip to 0 to avoid this as negative density messes up SOM learning
2618
return jnp.maximum(density, 0.)
2719

2820
def _euclidean_dist(a, b): ## Euclidean (L2) distance

0 commit comments

Comments
 (0)