Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 30 2019 17:07
    mstimberg commented #1047
  • Jan 30 2019 16:53
    thesamovar commented #1047
  • Jan 30 2019 15:40
    mstimberg commented #1047
  • Jan 30 2019 12:16
    daphn3cor closed #1048
  • Jan 30 2019 12:15
    daphn3cor commented #1048
  • Jan 30 2019 10:33
    mstimberg synchronize #1047
  • Jan 30 2019 10:33

    mstimberg on function_compiler_kwds

    Add .c and .pxd to the list of … Make Cython compilation quiet a… (compare)

  • Jan 30 2019 09:57
    mstimberg edited #1047
  • Jan 30 2019 09:56
    mstimberg synchronize #1047
  • Jan 30 2019 09:56

    mstimberg on function_compiler_kwds

    Document the new features for u… (compare)

  • Jan 30 2019 09:56
    mstimberg commented #1048
  • Jan 30 2019 07:59
    daphn3cor commented #1048
  • Jan 29 2019 16:30
    mstimberg commented #1048
  • Jan 29 2019 15:42
    daphn3cor opened #1048
  • Jan 29 2019 14:44
    mstimberg synchronize #1047
  • Jan 29 2019 14:44

    mstimberg on function_compiler_kwds

    Include external source files a… (compare)

  • Jan 29 2019 13:48
    mstimberg synchronize #1047
  • Jan 29 2019 13:48

    mstimberg on function_compiler_kwds

    Minor bug-fixes for new additio… Support external source files f… Add tests for functions with ex… (compare)

  • Jan 25 2019 17:34
    thesamovar commented #1047
  • Jan 25 2019 17:26
    mstimberg opened #1047
wxie2021
@wxie2021
[08:55:22] # /home/wxie/anaconda3/envs/brian2.5/lib/python3.8/site-packages/matplotlib/pycache/tight_layout.cpython-38.pyc matches /home/wxie/anaconda3/envs/brian2.5/lib/python3.8/site-packages/matplotlib/tight_layout.py
[08:57:34] # code object from '/home/wxie/anaconda3/envs/brian2.5/lib/python3.8/site-packages/matplotlib/pycache/tight_layout.cpython-38.pyc'
indeed related to matplotlib pycache
Marcel Stimberg
@mstimberg
Ah no, that's not what I had in mind. I was referring to matplotlib's font cache (something that gets stored in ~/.matplotlib). The __pycache__ directories are compiled bytecode (each .py file has a companion .pyc file). It is weird that loading this takes a long time...
wxie2013
@wxie2013
I suspect it's a WSL related issue corresponding to windows 10 21H2. Anyway, thanks for the help.
AreUTheDoctor
@AreUTheDoctor
just a quick question, is brian2 compatible with python 3.10?
Just tryna work out how comes I get "Found conflicts! Looking for incompatible package" as I installed brian2tools
Marcel Stimberg
@mstimberg
Hi @AreUTheDoctor , I'm going to reply on the discussion forum
AreUTheDoctor
@AreUTheDoctor
oh cheers, much grateful for your support in near christmas time :))))
Rihana Naderi
@RNaderi
I have a non-priodic signal. I want to give it to my network. As far as I know I can do it in 2 different forms :1) As an external current (I) 2) Over a single neuron connected to my network . Is it true?
wxie2013
@wxie2013
I'm wondering if it's possible to introduce neural-network based method to solve ODE in brian2. This might just speed up some of the simulations.
Marcel Stimberg
@mstimberg

I have a non-priodic signal. I want to give it to my network. As far as I know I can do it in 2 different forms :1) As an external current (I) 2) Over a single neuron connected to my network . Is it true?

Hi @RNaderi : you asked your question on the discussion forum as well, right? Let's follow up there if things are still unclear.

Marcel Stimberg
@mstimberg

I'm wondering if it's possible to introduce neural-network based method to solve ODE in brian2. This might just speed up some of the simulations.

Hi @wxie2013 . I'm not an expert on this topic, but the papers I've seen about solving ODEs with NNs were proof-of-concepts, showing that it is possible in general. I think it will be rather slower and not faster. Also, we have some quite good understanding of accuracy/stability properties of common ODE solvers, this is not the case for an approximation with NNs. But of course feel free to play around with this approach (e.g. by solving a common neuron model with the NN approach, without using Brian2) and let us know if you find that it is indeed considerably faster! Note that the time for solving ODEs is only really relevant for complex neuron models and small networks, otherwise everything connected to spike propagation dominates the simulation time.

Rihana Naderi
@RNaderi

I have a non-priodic signal. I want to give it to my network. As far as I know I can do it in 2 different forms :1) As an external current (I) 2) Over a single neuron connected to my network . Is it true?

Hi @RNaderi : you asked your question on the discussion forum as well, right? Let's follow up there if things are still unclear.

Thanks. Sure.

Where is the snapshot stored when I use "store" after simulation? I'd like to reuse my network without long simulation.
Marcel Stimberg
@mstimberg

Where is the snapshot stored when I use "store" after simulation? I'd like to reuse my network without long simulation.

If you use a simple store(), the snapshot is stored in memory, i.e. no longer available when the Python process ends. You can store things to disk using the filename argument, but note that this is not a general mechanism to store a model to disk, as explained in the documentation: https://brian2.readthedocs.io/en/stable/reference/brian2.core.network.Network.html#brian2.core.network.Network.store

Rihana Naderi
@RNaderi

Where is the snapshot stored when I use "store" after simulation? I'd like to reuse my network without long simulation.

If you use a simple store(), the snapshot is stored in memory, i.e. no longer available when the Python process ends. You can store things to disk using the filename argument, but note that this is not a general mechanism to store a model to disk, as explained in the documentation: https://brian2.readthedocs.io/en/stable/reference/brian2.core.network.Network.html#brian2.core.network.Network.store

Got it. Thank you very much for all information and help

Rihana Naderi
@RNaderi
Suppose an external input(I) driven by TimedArray. I'm trying to change it several times after run and run my network again with new inputs but it gives me an error : I is read-only. how can I change such input and run several times?
Rihana Naderi
@RNaderi
This is an example : I_recorded = TimedArray([0,0,1,1,0], dt=1ms)
G.I='I_recorded(t)' run(5
ms)
Marcel Stimberg
@mstimberg
Hi @RNaderi. You cannot change the values in a TimedArray, but you can define a new TimedArray for each run. If it has the same name, all references to that name will pick up the new values.
But note that G.I = 'I_recorded(t)' is very likely not doing what you want: this will set the initial value of G.I to the value of I_recorded(t) at that time, i.e. probably at t=0*ms. This means that the value will not change during the simulation. Instead, your equations need to include something like I = I_recorded(t) : amp to state the current gets its values from the TimedArray.
Rihana Naderi
@RNaderi

Hi @RNaderi. You cannot change the values in a TimedArray, but you can define a new TimedArray for each run. If it has the same name, all references to that name will pick up the new values.
But note that G.I = 'I_recorded(t)' is very likely not doing what you want: this will set the initial value of G.I to the value of I_recorded(t) at that time, i.e. probably at t=0*ms. This means that the value will not change during the simulation. Instead, your equations need to include something like I = I_recorded(t) : amp to state the current gets its values from the TimedArray.

I also did it , while it will run on the last value of my oId I_recorded(t) : "0" ( I_recorded(t) = TimedArray([1,1,0], dt=1ms) ) , and can't see my new input (I_recorded=TimesArray([0,0,1,1,0], dt=1ms) ). I want to run another run for new inputs of different timedArray imidiately after finishing a long run . But it doesn't get new inputs and repeat on the last values of ole I_recorded

Marcel Stimberg
@mstimberg
TimedArrayentries correspond to the time starting at 0s. If you continue a run, the time will not be at 0s anymore, so it will not use the values at the start of the new TimedArray. Either create a single TimedArray with the values for all the inputs one after the other (so values for the first input will be at, say, 0ms, values for the second input start at 3ms, etc.), or use the store/restore functionality to restart the simulation at 0s.
Rihana Naderi
@RNaderi
@mstimberg I store my state and after that restore and replace I_recorded with new one but again it runs on the last values of the previous I_recorded.
Marcel Stimberg
@mstimberg
Ok, in that case it is hard to determine what is going on without seeing the actual code you use. Ideally, you'd simplify the code as much as possible before posting.
Rihana Naderi
@RNaderi
@mstimberg Thanks for the hints. I found what the issue is. I added an offset_time to I_recorded(t)--->> I_recorded(t-offset_time). and after restoring the network I should update this variable because Brian seems to consider only state variables during restoring not internal ones such as offset.
Rihana Naderi
@RNaderi
Hi again! How to remove unit of a variable?
Marcel Stimberg
@mstimberg
You can divide by the unit or use functions like float (for a scalar value) or np.array (for an array). See https://brian2.readthedocs.io/en/stable/user/units.html#removing-units
Rihana Naderi
@RNaderi
Many thanks for all supports @mstimberg
Rihana Naderi
@RNaderi
Hi everyone! I'd like to assign an index based on post synaptic neuron index to my synapses(S). suppose that I have 5 synapses { (0,1),(0,0),(1,2),(3,4),(4,0) }. the index of each synapse will have to be {1,0,2,4,0}. also I have an input variable named "index" for my synapse model. I don't know how to assign S.index .
Marcel Stimberg
@mstimberg
Hi @RNaderi . The post-synaptic neuron index is always available as the special variable named j. So you could directly use that, or if you need to assign it to your own index variable for some reason, use S.index = 'j'.
Rihana Naderi
@RNaderi
Thanks . If I want to assign an index from a specific range , how to do it ? for example from 0 to 100 randomly.
Marcel Stimberg
@mstimberg
Hi @RNaderi . Not sure I understand correctly: you want to set index to a random number instead of to the post-synaptic index? To set a variable index to a random number between 0 and 100 (i.e. up to 99), you can use S.index = 'int(rand()*100)', but this will lead to some repeated and some missing values. To not repeat indices, you'll have to use numpy instead of Brian's string expression framework. E.g., S.index = np.choice(100, replace=False, size=100).
Rihana Naderi
@RNaderi
Many thanks @mstimberg
AreUTheDoctor
@AreUTheDoctor

When I copied-paste the code at the end of the Brian tutorial part 1, there was an error at this line
x = hist(spikemon.t/ms, 100, histtype='stepfilled', facecolor='k', weights=list(ones(len(spikemon))/(N*defaultclock.dt)))

it said "ValueError: weights should have the same shape as x"

7 replies
wxie2021
@wxie2021
For a <class 'brian2.units.fundamentalunits.Quantity'>, what is the best way to strip the unit and just get the number. For example: 9. ms and I just need to get 9.
1 reply
VigneswaranC
@Vigneswaran-Chandrasekaran

For a <class 'brian2.units.fundamentalunits.Quantity'>, what is the best way to strip the unit and just get the number. For example: 9. ms and I just need to get 9.

You can use, float(9*ms) to get the numerical part, but it returns in SI unit For eg. 0.009

1 reply
AreUTheDoctor
@AreUTheDoctor
Is it possible to train an SNN to do image classification? Just for fun and novelty :P
AreUTheDoctor
@AreUTheDoctor
And is it possible to simulate the spike shape or firing rate of a CNN?
Marcel Stimberg
@mstimberg
Everything is possible, but Brian is not necessarily the best tool for SNNs in machine learning settings (e.g. something like the "shared weights" of a CNN is not a built-in feature of Brian). There were a few discussions in the Brian discussion forum that touch on similar subjects, though. E.g. https://brian.discourse.group/t/unsupervised-learning-of-digit-recognition-using-spike-timing-dependent/189 or https://brian.discourse.group/t/pattern-recognition-in-spiking-neural-nets-using-brian2/141
Rihana Naderi
@RNaderi
Hi, suppose I have two inputs(defined by TimedArray) for my network with STDP on synapses, and also my network will simulate for two run continuously because of two inputs.
I initialized my weights with 'rand()' after connecting synapses.
my question is that after first run it will continue with new weights which have changed with STDP rule or it reset to weight initialization for next run?
Rihana Naderi
@RNaderi
how about when I import my weights as initialization instead of rand()?
Marcel Stimberg
@mstimberg
Hi. If you have two run(...) statements, then the second one will continue where the previous simulation stopped. This includes all variables such as synaptic weights. Statements like S.w = 'rand()' are only executed at the point in the code where they are written. They do not get automatically re-executed for a second run.

how about when I import my weights as initialization instead of rand()?

Not sure I understand, you mean when you initialize weights with some concrete values S.w = some_values ? This does not change anything, this assignment is executed only once like any other assignment.

Rihana Naderi
@RNaderi
thx @mstimberg
Rihana Naderi
@RNaderi
Hi, I have 2 groups of neurons(exc and inh) and synapses between exc to inh. now I'm going to connect inh to exc neurons which don't receive any connections from them with a specific probability. how can I do it?
Marcel Stimberg
@mstimberg
Hi @RNaderi . Would you mind asking this question on https://brian.discourse.group ? It's not a simple answer, and I think others could benefit from it. Thanks!
Rihana Naderi
@RNaderi

Hi @RNaderi . Would you mind asking this question on https://brian.discourse.group ? It's not a simple answer, and I think others could benefit from it. Thanks!

for sure. I thought it would be short. That was why I asked here. Thank you.

fededalba
@fededalba
Hello! I need to run 50 long simulations while changing a parameter and i need to change temporal step after the first 10. I have defined a Clock object and passed it to all my objects, then i have defined a Network object so i can store, change the parameter and then restore with the new value. At the tenth cycle i change the clock in this way clk.dt_ = 0.00001. (because using clk.dt = 0.001 ms doesnt change anything). I was wondering if there is an easier way to do it without using private attributes.
and if it is correct as procedure or i risk to obtain wrong result?
Marcel Stimberg
@mstimberg
Could you maybe give a little example with some minimal example code (might be better on https://brian.discourse.group)? I did not quite understand in what way you store/restore/run and when exactly you change the clock. Note that clk.dt_ is not a private attribute (that would be clk._dt), the ..._ syntax is just the value without the units, and normally setting clk.dt_ = ... or clk.dt = 0.00001 or clk.dt = 0.001*ms should do the exact same thing. That value seems to be a bit on the tiny side, though.
Rihana Naderi
@RNaderi
Hi all, this is my poissoninput : p=PoissonInput(neurons,'g_e',1, 5Hz, 1nS) . I want to run it again after first run with a new rate(p.rate=3*Hz),but I recieve a message :can't set attribute. how can I do this?