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 77
88def _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
1312def _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
2820def _euclidean_dist (a , b ): ## Euclidean (L2) distance
You can’t perform that action at this time.
0 commit comments