[nengo-user] normalized average of a variable x over n ensembles of neurons
Terry Stewart
terry.stewart at gmail.com
Tue Feb 9 10:31:04 EST 2016
Hello Peer,
Thank you for the question! I'm not quite sure exactly what you're
trying to compute here, though -- if the neurons are representing some
vector x, then that means that their activity a_i should itself be a
function of x. And if that's the case, then I'm not quite sure what
it would mean to compute a weighted average when the weighting factor
a_i is itself a function of x. Do you want to control a_i
independently of x_i? Or are they supposed to be so tightly coupled?
Could you give a little more context of what you're trying to do here?
What are the inputs and outputs that you want? One possible thing
that's coming to mind is that you've got two inputs: the vector x and
the vector a, and you want to compute \sum_i^n a_i x_i / \sum_1^n a_i.
This isn't quite what you asked, as I now have a_i and x_i as just two
different things being represented by the neurons, rather than a_i
being a direct measure of the activity of the neurons. But if that's
what you wanted, then this is how it could be done in nengo:
----------
import nengo
import numpy as np
model = nengo.Network()
with model:
D = 4
stim_x = nengo.Node([0]*D) # the values to average
stim_a = nengo.Node([0.3]*D) # the weights to apply when doing the average
ens = nengo.Ensemble(n_neurons=2000, dimensions=D*2)
nengo.Connection(stim_x, ens[:D])
nengo.Connection(stim_a, ens[D:])
result = nengo.Ensemble(n_neurons=50, dimensions=1)
def weighted_average(x):
a = x[D:]
x = x[:D]
return sum(a*x)/sum(a)
# this should give sample data that you want the neurons
# to be good at
def make_sample():
x = np.random.uniform(-1,1,size=D)
a = np.random.uniform(0,1,size=D)
return np.hstack([x, a])
nengo.Connection(ens, result, function=weighted_average,
eval_points=[make_sample() for i in range(4000)])
--------------
One slightly uncommon thing that's being done in that code is the
eval_points, which I'm using to make sure that nengo doesn't try to
optimize the neural connections across the whole space, which would
include *negative* values for a_i. Trying to optimize over the whole
space is often too difficult and unneeded, so we tend to try to just
optimize over the part of the space that's needed (as given by the
make_sample() function).
Still, I'm not quite sure this solves your problem, but maybe it's a
step in the right direction. Let me know how I'm misinterpreting
things and I can make another attempt at solving the problem!
:)
Terry
On Mon, Feb 8, 2016 at 6:49 PM, Peer Ueberholz <peer at ueberholz.de> wrote:
> Hi
>
> I want to compute a normalized average of a variable x over n ensembles of
> neurons
>
> \bar{x} = \sum_i^n a_i x_i / \sum_1^n a_i
>
> where a_i is the activity of each ensemble, \sum_1^n a_i the sum over the
> activities of the n ensembles and x_i the value of a variable x assigned to
> ensemble i.
>
> To implement the sum is possible, although not entirely straightforward.
> However, the division seems to represent a more serious problem. A possible
> solution that I've tried is to avoid division is to use logarithms, but this
> doesn't appear to help much either. Does anyone know a simple method to
> compute this quantity in Nengo?
>
>
> Thanks,
>
> Peer
>
> _______________________________________________
> nengo-user mailing list
> nengo-user at ctnsrv.uwaterloo.ca
> http://ctnsrv.uwaterloo.ca/mailman/listinfo/nengo-user
More information about the nengo-user
mailing list