khengyeww / sym-STDP

Hao's sym-STDP-SNN model
5 stars 0 forks source link

from bindsnet.analysis.plotting import ( plot_input, plot_spikes, plot_conv2d_weights, plot_voltages, ) #3

Closed tehreemnaqvi closed 4 years ago

tehreemnaqvi commented 4 years ago

Hi, I want to plot input spikes, conv2d_weights, voltages. But I am confused how from bindsnet.analysis.plotting works? Can you please how can I visualize all these? Thanks

khengyeww commented 4 years ago

I assume this is more a question to BindsNET rather than this repo.

You can run this sample (which uses conv layer) provided by BindsNET with --plot flag. It uses the functions you mentioned and visualize them.

tehreemnaqvi commented 4 years ago

Got it. Thank you

tehreemnaqvi commented 4 years ago

Hi, Below is my code.I am trying to show the plot but couldn't do this. What's the problem here? Can you please help? Thanks

Optionally plot various simulation information.

    if plot:
        image = batch["image"].view( 28, 28 )

        inpt = inputs["X"].view( time, 784 ).sum( 0 ).view( 28, 28 )
        weights1 = conv_conn.w
        _spikes = {
            "X": spikes["X"].get( "s" ).view( time, -1 ),
            "Y": spikes["Y"].get( "s" ).view( time, -1 ),
        }
        _voltages = {"Y": voltages["Y"].get( "v" ).view( time, -1 )}

        inpt_axes, inpt_ims = plot_input(
            image, inpt, label=label, axes=inpt_axes, ims=inpt_ims
        )
        spike_ims, spike_axes = plot_spikes( _spikes, ims=spike_ims, axes=spike_axes )
        weights1_im = plot_conv2d_weights( weights1, im=weights1_im )
        voltage_ims, voltage_axes = plot_voltages(
            _voltages, ims=voltage_ims, axes=voltage_axes
        )

        plt.ioff()
        plt.show()