# === Save the results, optionally plot a figure ============================= filename = normalized_filename("Results", "simple_stdp", "pkl", options.simulator) p2.write_data(filename, annotations={'script_name': __file__}) presynaptic_data = p1.get_data().segments[0] postsynaptic_data = p2.get_data().segments[0] print("Post-synaptic spike times: %s" % postsynaptic_data.spiketrains[0]) weights = weight_recorder.get_weights() final_weights = numpy.array(weights[-1]) deltas = delta_t * numpy.arange(n // 2, -n // 2, -1) print("Final weights: %s" % final_weights) plasticity_data = DataTable(deltas, final_weights) if options.fit_curve: def double_exponential(t, t0, w0, wp, wn, tau): return w0 + numpy.where(t >= t0, wp * numpy.exp(-(t - t0) / tau), wn * numpy.exp((t - t0) / tau)) p0 = (-1.0, 5e-8, 1e-8, -1.2e-8, 20.0) popt, pcov = plasticity_data.fit_curve(double_exponential, p0, ftol=1e-10) print( "Best fit parameters: t0={0}, w0={1}, wp={2}, wn={3}, tau={4}".format( *popt)) if options.plot_figure: from pyNN.utility.plotting import Figure, Panel, DataTable
# === Save the results, optionally plot a figure ============================= filename = normalized_filename("Results", "simple_stdp", "pkl", options.simulator) p2.write_data(filename, annotations={"script_name": __file__}) presynaptic_data = p1.get_data().segments[0] postsynaptic_data = p2.get_data().segments[0] print("Post-synaptic spike times: %s" % postsynaptic_data.spiketrains[0]) weights = weight_recorder.get_weights() final_weights = numpy.array(weights[-1]) deltas = delta_t * numpy.arange(n // 2, -n // 2, -1) print("Final weights: %s" % final_weights) plasticity_data = DataTable(deltas, final_weights) if options.fit_curve: def double_exponential(t, t0, w0, wp, wn, tau): return w0 + numpy.where(t >= t0, wp * numpy.exp(-(t - t0) / tau), wn * numpy.exp((t - t0) / tau)) p0 = (-1.0, 5e-8, 1e-8, -1.2e-8, 20.0) popt, pcov = plasticity_data.fit_curve(double_exponential, p0, ftol=1e-10) print("Best fit parameters: t0={0}, w0={1}, wp={2}, wn={3}, tau={4}".format(*popt)) if options.plot_figure: from pyNN.utility.plotting import Figure, Panel, DataTable