def plot_2d_input_weights():
    name = 'XeAe'
    weights = get_2d_input_weights()
    fig = b2.figure(fig_num, figsize = (18, 18))
    im2 = b2.imshow(weights, interpolation = "nearest", vmin = 0, vmax = wmax_ee, cmap = cmap.get_cmap('hot_r'))
    b2.colorbar(im2)
    b2.title('weights of connection' + name)
    fig.canvas.draw()
    return im2, fig
Пример #2
0
def plot_2d_input_weights():
    name = 'XeAe'
    weights = get_2d_input_weights()
    fig = b2.figure(fig_num, figsize = (18, 18))
    im2 = b2.imshow(weights, interpolation = "nearest", vmin = 0, vmax = wmax_ee, cmap = cmap.get_cmap('hot_r'))
    b2.colorbar(im2)
    b2.title('weights of connection' + name)
    fig.canvas.draw()
    return im2, fig
Пример #3
0
def plot_performance(fig_num):
    num_evaluations = int(num_examples/update_interval)
    time_steps = range(0, num_evaluations)
    performance = np.zeros(num_evaluations)
    fig = b2.figure(fig_num, figsize = (5, 5))
    fig_num += 1
    ax = fig.add_subplot(111)
    im2, = ax.plot(time_steps, performance) #my_cmap
    b2.ylim(ymax = 100)
    b2.title('Classification performance')
    fig.canvas.draw()
    return im2, performance, fig_num, fig
def plot_performance(fig_num):
    num_evaluations = int(num_examples/update_interval)
    time_steps = range(0, num_evaluations)
    performance = np.zeros(num_evaluations)
    fig = b2.figure(fig_num, figsize = (5, 5))
    fig_num += 1
    ax = fig.add_subplot(111)
    im2, = ax.plot(time_steps, performance) #my_cmap
    b2.ylim(ymax = 100)
    b2.title('Classification performance')
    fig.canvas.draw()
    return im2, performance, fig_num, fig
Пример #5
0
    def show_event_monitor(self,
                           monitor,
                           window='',
                           figure_title='',
                           xlab='Time (ms)',
                           ylab='Neuron Index',
                           marker='o',
                           use_grid=True,
                           is_figure=True):
        """
        Plots a cloud chart for a specific `EventMonitor`.

        Parameters
        ----------
        monitor : str
            Name of the `EventMonitor`.
        window : str, optional
            Name of the window. Defaults to ``monitor``.
        figure_title : str, optional
            Name of the figure.
            Defaults to 'Firing of ``event`` events during simulation'.
        ylab : str, optional
            Y-axis label.
        xlab : str, optional
            X-axis label.
        marker : str, optional
            Marker style.
        use_grid : bool, optional
            Is the grid activated?
        """
        if is_figure:
            figure(monitor if window == '' else window)
            title('Firing of {} events during simulation'.
                  format(self._event_monitors[monitor]) if figure_title ==
                  '' else figure_title)
        scatter(self[monitor].t / ms, self[monitor].i, marker=marker)
        xlabel(xlab)
        ylabel(ylab)
        if use_grid:
            grid()

        pause(0.001)
Пример #6
0
    save_connections()
else:
    np.save(data_path + 'activity/resultPopVecs' + str(num_examples), result_monitor)
    np.save(data_path + 'activity/inputNumbers' + str(num_examples), input_numbers)


#------------------------------------------------------------------------------
# plot results
#------------------------------------------------------------------------------
if rate_monitors:
    b2.figure(fig_num)
    fig_num += 1
    for i, name in enumerate(rate_monitors):
        b2.subplot(len(rate_monitors), 1, 1+i)
        b2.plot(rate_monitors[name].t/b2.second, rate_monitors[name].rate, '.')
        b2.title('Rates of population ' + name)

if spike_monitors:
    b2.figure(fig_num)
    fig_num += 1
    for i, name in enumerate(spike_monitors):
        b2.subplot(len(spike_monitors), 1, 1+i)
        b2.plot(spike_monitors[name].t/b2.ms, spike_monitors[name].i, '.')
        b2.title('Spikes of population ' + name)

if spike_counters:
    b2.figure(fig_num)
    fig_num += 1
    b2.plot(spike_monitors['Ae'].count[:])
    b2.title('Spike count of population Ae')
                                                  density=True,
                                                  range=(0., 1.))[0]

    b2.figure(figsize=(4, 4))
    im = b2.imshow(
        rates_weight_histograms,
        origin='lower',
        extent=[postsyn_rates[0] / b2.Hz, postsyn_rates[-1] / b2.Hz, 0, 1],
        aspect='auto',
        cmap=b2.plt.cm.gray_r)
    # b2.colorbar(label='probability density')
    b2.xlabel("Postsynaptic Firing Rate (Hz)")
    # b2.ylabel(r"$\frac{w}{w_{max}}$", rotation=0)
    b2.ylabel("$w/w_{max}$")
    b2.title(
        'Synaptic Strength Distributions\nas function of postsynaptic firing rate'
    )
    b2.savefig('images_and_animations/synaptic_strengths_vs_firing_rates.png')
    # b2.show()

    b2.figure(figsize=(4, 4))
    im = b2.imshow(mu_weight_histograms,
                   origin='lower',
                   extent=[0, 1, 0, 1],
                   aspect='auto',
                   cmap=b2.plt.cm.gray_r)
    # b2.colorbar(label='probability density')
    # b2.xticks(np.linspace(0., 1., 5)**2)
    b2.xlabel("$\mu$")
    # b2.ylabel(r"$\frac{w}{w_{max}}$", rotation=0)
    b2.ylabel("$w/w_{max}$")
    save_connections()
else:
    np.save(data_path + 'activity/resultPopVecs' + str(num_examples), result_monitor)
    np.save(data_path + 'activity/inputNumbers' + str(num_examples), input_numbers)


#------------------------------------------------------------------------------
# plot results
#------------------------------------------------------------------------------
if rate_monitors:
    b2.figure(fig_num)
    fig_num += 1
    for i, name in enumerate(rate_monitors):
        b2.subplot(len(rate_monitors), 1, 1+i)
        b2.plot(rate_monitors[name].t/b2.second, rate_monitors[name].rate, '.')
        b2.title('Rates of population ' + name)

if spike_monitors:
    b2.figure(fig_num)
    fig_num += 1
    for i, name in enumerate(spike_monitors):
        b2.subplot(len(spike_monitors), 1, 1+i)
        b2.plot(spike_monitors[name].t/b2.ms, spike_monitors[name].i, '.')
        b2.title('Spikes of population ' + name)

if spike_counters:
    b2.figure(fig_num)
    fig_num += 1
    b2.plot(spike_monitors['Ae'].count[:])
    b2.title('Spike count of population Ae')
Пример #9
0
    def show_state_monitor(self,
                           monitor,
                           window='',
                           figure_title='',
                           name='Element {}',
                           name_values=None,
                           linestyle='-',
                           xlab='Time (ms)',
                           ylab='',
                           use_grid=True,
                           is_figure=True):
        """
        Plots a line chart for a specific `StateMonitor`.

        Parameters
        ----------
        monitor : str
            Name of the `StateMonitor`.
        window : str, optional
            Name of the window. Default value is ``monitor``.
        figure_title : str, optional
            Name of the figure.
            Default value 'Evolution of ``variable`` over time'.
        name : str, optional
            Name of each set. `{}` is replaced by the set ID.
        name_values list of str, optional
            Values replacing the set IDs for ``name``.
        linestyle : str, optional
            Line style.
        xlab : str, optional
            X-axis label.
        ylab : str, optional
            Y-axis label. Default value is '``variable`` (`dimension`)'.
        use_grid : bool, optional
            Is the grid activated?

        Warnings
        --------
        `dimension` of Volt is "m^2 kg s^-3 A^-1"!
        """
        var = self._state_monitors[monitor]
        values = getattr(self[monitor], var)

        try:
            dim = values.dim
        except AttributeError:
            dim = '1'
        if is_figure:
            figure(monitor if window == '' else window)
            title('Evolution of {} over time'.format(var) if figure_title ==
                  '' else figure_title)
        i = 0
        for v in values:
            plot(
                self[monitor].t / ms,
                v,
                linestyle=linestyle,
                label=(
                    name.format(i if name_values is None else name_values[i])))
            i += 1
        xlabel(xlab)
        ylabel('{} ({})'.format(var, dim) if ylab == '' else ylab)
        if use_grid:
            grid()
        if name != '':
            legend()