[nengo-user] function approximation problem
Terry Stewart
terry.stewart at gmail.com
Sat Mar 9 23:12:00 EST 2013
> Next Problem which i am facing is in function approximation-
> Sir i want to solve a function approximation problem in which i have to take
> data from a file and then find out the appropriate function which fits on
> them...how can i solve this using nengo?( as in matlab we use to take
> different order equations and which ever plot fits better we approximate it
> with that function).
Hmm, good question. That should be possible, since what Nengo does
with the function you give it is sample the function: it randomly
generates a bunch of input values and then evaluates the function at
those points. So it's generating exactly the sort of data that you
want to give it, so we should be able to tell Nengo to just bypass
that process and use the data you have directly.
That said, I don't think we have a nice way to do that right now. It
should be an easy thing to add, but I'd have to take some time to
figure out where the best place to add it would be. For now, though
here's a way to work around it:
1) set the eval_points parameter to the list of input values. This
specifies that this set of points should be used when finding decoders
2) write a function that implements a look-up table on your training
data, and use it in the net.connect() command. Nengo will take that
function and call it once for each of the elements in eval_point, and
use the resulting data to solve for a set of connection weights that
approximates the lookup table.
Here's a quick example that implements XOR:
------------
import nef
input=[[1, 1], [-1, 1], [1, -1], [-1, -1]]
output=[[1], [-1], [-1], [1]]
net=nef.Network('Lookup')
net.make('A', neurons=100, dimensions=2, eval_points=input)
net.make('B', neurons=100, dimensions=1)
def lookup(x):
dist=None
index=None
for i,v in enumerate(input):
d=(v[0]-x[0])**2+(v[1]-x[1])**2
if dist is None or d<dist:
index=i
dist=d
return output[index]
net.connect('A', 'B', func=lookup)
net.make_input('input', [1,1])
net.connect('input', 'A')
net.add_to_nengo()
--------------------
>I was also readying a paper which was telling me about
> encoding and decoding equations But i dont understand how and where to apply
> them.Please help me out....
Hmm, which paper was this? What sort of encoding and decoding
equations? For the most part, Nengo takes care of using the core
equations to create the encoders and decoders for you. What sort of
thing are you trying to do?
:)
Terry
More information about the nengo-user
mailing list