Synapse simulation

HI
I have a question about simulating synapses in nengo;
As I find out we can only set a value for synapse not to simulate a synapse . Is there any way to simulate synapse in nengo?

Nengo simulates a fairly broad class of synapses. By default, the value of the synapse is mapped onto the time-constant of a lowpass (exponentially decaying) synapse, which is then simulated by Nengo to filter some input. Below is an example of how Nengo can be used to simulate an Alpha synapse, but it can do much more, and in many different contexts. Could you expand a bit on what you would like to do?

alpha

import matplotlib.pyplot as plt
import nengo

# here you have a choice between many different objects
# or just a single time-constant for an exponential decay (lowpass)
synapse = nengo.Alpha(0.1)
dt = 1e-3

with nengo.Network() as model:
    
    # Emit a spike with an integral of 1
    u = nengo.Node(output=lambda t: int(t <= dt) / dt)

    # Store the output of a synapse
    y = nengo.Node(size_in=1)
    
    # Simulate a synapse given u as input and y as output
    nengo.Connection(u, y, synapse=synapse)
    
    # Probe the output for plotting
    p = nengo.Probe(y, synapse=None)  # no additional filtering

with nengo.Simulator(model, dt=dt) as sim:
    sim.run(1.0)
    
plt.figure()
plt.plot(sim.trange(), sim.data[p], label=str(synapse))
plt.xlabel("Time (s)")
plt.ylabel("Output")
plt.legend()
plt.show()

Thanks for your replying

I want to use memristor for simulating depression ,pattern recognition,hand writing recognition and probably learning rules such as spike time dependence plasticity.How can I read about the ways synapses can be applied in nengo?

I dont know which package is appropriate ;nengo ,nest or another package.As I have worked with C++ before, I prefer to be able to code in C++ but the code tools are more important.

Synapses can be applied within a model on any nengo.Connection(...) between two objects, as in:

nengo.Connection(pre, post, ..., synapse=synapse, ...)

This has the effect of applying the transfer function described by synapse to the signal produced by pre, and then adding the result to the signal that is driving post.

nengo.synapses.LinearFilter allows you to define any synapse that can be described as a transfer function. For nonlinear dynamics, you could write your own synapse object and register it with the Nengo builder.

A more direct way would be to encapsulate the equations that you want inside of a nengo.Node(...) and then connect in and out of that. The function supplied to a nengo.Node can be any arbitrary code, called each time-step, to tell Nengo what the output(s) of the node should be given its input(s) at the current moment of time.

Nengo is a very general-purpose tool for constructing neural networks. If you need components of the neural network to be arbitrary code, and then be able to hook those components up to other neural networks, then Nengo is quite appropriate.

Code written in numpy is executed in C (under the hood), and is generally much more convenient than writing equivalent vector math directly in C++. Custom snippets of numpy code can be easily incorporated into Nengo networks. If a significant amount of your code is already written in C++, and porting it over looks to be like too much work, then it may be possible to reuse some of it in Nengo with a library like SWIG to interface between Python and C++, and then calling that interface from inside of a nengo.Node(...).