Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDNNs and SNNs #269

Open
Kristi1217 opened this issue Dec 5, 2023 · 0 comments
Open

SDNNs and SNNs #269

Kristi1217 opened this issue Dec 5, 2023 · 0 comments

Comments

@Kristi1217
Copy link

Hi @bamsumit @tangores ,

I tried using psp0 to convert the inputs into binary spikes then the psp0 is sent SDNN layers.

  1. Is there a way to verify that the input was converted? because I don't see much difference while training a network, if it takes in normal channels or binary spikes, it computes at the same rate.

  2. My forward operations looks something like this. Secondly I cant change number of output channels, I have to then to create separate blocks.


      self.blocks = torch.nn.ModuleList([
          slayer.block.sigma_delta.Conv(sdnn_params1,  2, 2, 3, padding=1),            
          slayer.block.sigma_delta.Conv(sdnn_params1,  2, 2, 1, padding=0), 
      ])
     
      
  def forward(self, x):
      count = []
      event_cost = 0
      device = torch.device("cuda")  # or "cpu" if you want to use the CPU

      scale = 1#<<12 # scale factor for integer simulation
      decay = torch.FloatTensor([0.1 * scale]).to(device)
      initial_state = torch.FloatTensor([0]).to(device)
      threshold = 0.5
      
      B, C, H, W, T = x.shape
      
      psp = slayer.neuron.dynamics.leaky_integrator._li_dynamics_fwd(x, decay=decay, state=initial_state, w_scale=scale,threshold= threshold)  
      
         
      for block in self.blocks:
          x = block(psp)
          if hasattr(block, 'neuron'):
              event_cost += event_rate_loss(x)
              count.append(torch.sum(torch.abs((x[..., 1:]) > 0).to(x.dtype)).item())
              
      return x, event_cost, torch.FloatTensor(count).reshape((1, -1)).to(x.device)

Originally posted by @Kristi1217 in #225 (comment)

@Kristi1217 Kristi1217 changed the title Hi @bamsumit @tangores , SDNNs and SNNs Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant