tudelft / cuSNN

Spiking Neural Networks in C++ with strong GPU acceleration through CUDA
GNU General Public License v3.0
121 stars 24 forks source link

Parameters for roadmap #1

Open 00Sim opened 4 years ago

00Sim commented 4 years ago

Hello,

Thank you for the great work! I am trying to look at spike outputs from the cuSNN-samples roadmap data using what I believe are the parameters from the paper. The SSConv layer spikes work great and look like the paper results, but the MSConv layer's spikes are very very sparse (just a few spikes if any at all).

This was tested using the MSConv-test file and pretrained weights for roadmap data. Are these the correct parameters (from main.cpp)?

const std::string dataset_dir = "../data/roadmap";
const int inp_size[] = {2, 264, 320}
const float inp_scale[] = {2.f, 2.f}; // (height, width)

// simulation settings
const int runs = 1000000;
const float sim_time = 150.f; // ms
const float sim_step = 1.f; // ms
const float sim_int = 1.f; // sim_steps input integration
const float scale_ets = 1.f;

const bool openGL = true;
const bool load_model = true;
const bool store_model_it = true;
const bool record_activity = false;
const bool data_augmentation = true;
const int store_model_it_gap = -1;
std::vector<int> kernels_display_idx = {0, 128};
std::string weights_dir = "../weights/roadmap";
std::string snapshots_dir = "../cuSNN_snapshots";

// neuron and synapse models
float neuron_refrac = 1.f; // ms
float synapse_trace_init = 0.15f;

bool inhibition = true;
bool drop_delays = false;
float drop_delays_th = 0.5f;

The original code is the same except for a few changes as I was getting compile errors:

1) Throughout plotter.cpp and data.cpp: Changed SNN->cnt_layers to SNN->h_cnt_layers[0]

2) Line 683: Changed float value = this->SNN->h_layers[l]->h_kernels[kernel]->h_node_posttrace[node_index]; to float value = this->SNN->h_layers[l]->h_kernels[kernel]->h_node_train[node_index];

Thanks! Simin

fedepare commented 4 years ago

Hi @UberSim,

Sorry for the late reply!

The only changes (besides those that you already highlighted) that are required to make test-MSConv to work with the roadmap pre-trained weights are required in the definition of the structure of the network:

/* NETWORK STRUCTURE */
    /* void add_layer(std::string layer_type, bool learning, bool load_weights, bool homeostasis, float Vth,
                       float decay, float alpha, float max_delay = 1.f, int num_delays = 1,
                       float synapse_inh_scaling = 0.f, int rf_side = 7, int out_channels = 8,
                       std::string padding = "none", float w_init = 0.5f); */
    SNN->h_layers = (Layer **) malloc(sizeof(Layer*) * 5);
    SNN->add_layer("Conv2d", false, true, true, 0.3f, 5.f, 0.1f, 1.f, 1, 0.f, 5, 16, "half");
    SNN->add_layer("Merge", false, true, false, 0.000001f, 5.f, 1.f);
    SNN->add_layer("Conv2d", false, true, true, 0.3f, 30.f, 0.1f, 25.f, 10, 0.5f, 5, 64, "half");
    SNN->create_network(break_sim);

I just tested this code with your changes and it works. Note that you can vary the output activity that you get from each layer by varying the threshold of its neurons and the scaling factor of the inhibitory weights. Please let me know if you have any other question!

Thank you very much for using cuSNN and for highlighting those bugs, I will take care of them unless you want to contribute with a pull request!

Cheers, Fede

00Sim commented 4 years ago

Hi Fede,

Thank you very much for the response! It seems like there may still be other errors in the modification I made as the MSConv spikes don't seem to be showing up. Thank you for testing the code with the changes, would be great to see the changes you made!

Thanks, Simin