Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/jacopobono/learning_cognitive_maps_code
24 February 2026, 16:03:07 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/first_branch
    • refs/heads/main
    No releases to show
  • a516681
  • /
  • supplementary_bias_current_simulations.py
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:dd585ba1064c00be7d60c4ebb7d063c68610b117
origin badgedirectory badge
swh:1:dir:a5166815043fc36f4e804ba90d29164f34c7006b
origin badgerevision badge
swh:1:rev:d86b262545547353c7050bbc2d476c2f4a297989
origin badgesnapshot badge
swh:1:snp:3e11e29283bbaf71786af24d2d77c12596b6e584

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: d86b262545547353c7050bbc2d476c2f4a297989 authored by Jacopo Bono on 26 January 2023, 19:15:51 UTC
somewhat cleaner scripts
Tip revision: d86b262
supplementary_bias_current_simulations.py
import numpy as np
import matplotlib.pyplot as plt
# import os


fs = 16

Ts = [50, 100, 200, 400]
biases = {}
gammas = {}
lambdas = {}

for T in Ts:

    alphas = np.arange(0,1,0.1)
    alphas[0] += 0.01

    A_plus= 1
    eta_stdp= 0.003 #0.002
    rate_ca3= 0.1
    step= 0.01
    tau_m= 2
    tau_plus= 60 #20
    N_post=1
    N_pre_tot=1
    N_pre=250
    eps0 = 1/N_pre

    # Total time in a state
    # T = 100

    theta = alphas*T
    delay = (1-alphas)*T

    # Calculation for parameter A
    A1 = N_pre*rate_ca3*(1-np.exp(-theta/tau_m))*(theta-tau_plus*(1-np.exp(-theta/tau_plus)))
    # A1 = 1*rate_ca3*(1-np.exp(-theta/tau_m))*(theta-tau_plus*(1-np.exp(-theta/tau_plus)))
    A2 = theta/((tau_m+tau_plus))

    # Depression amplitude
    max_ltd = - A_plus*tau_m*tau_plus*(A1+A2)/theta
    A_pre = -11
    A_LTD = A_pre*rate_ca3*theta

    # Parameter A
    A = eta_stdp*(eps0*A_plus*rate_ca3*tau_m*tau_plus*(A1+A2) + A_LTD)
    # A = eta_stdp*(1*A_plus*rate_ca3*tau_m*tau_plus*(A1+A2) + A_LTD)

    # Parameter C
    C = eps0*eta_stdp*A_plus*rate_ca3*tau_plus*(np.exp(theta/tau_plus)-1)*N_pre*rate_ca3*tau_m*(1-np.exp(-theta/tau_m))*tau_plus*(1-np.exp(-theta/tau_plus))
    # C = 1*eta_stdp*A_plus*rate_ca3*tau_plus*(np.exp(theta/tau_plus)-1)*1*rate_ca3*tau_m*(1-np.exp(-theta/tau_m))*tau_plus*(1-np.exp(-theta/tau_plus))

    # Learning rate
    eta = -A

    # Lambda
    lambda_var = 1/(1+C/eta)

    # Gamma
    gamma_var = np.exp(-T/tau_plus)/lambda_var

    # Parameter D
    D = eta_stdp*rate_ca3*A_plus*tau_plus*(1-np.exp(-theta/tau_plus))*tau_plus*(1-np.exp(-(T-theta)/tau_plus))

    a = (A_plus*eps0*tau_m*tau_plus*(rate_ca3+1/(tau_plus+tau_m)) + A_pre)
    b = -1*A_plus*eps0*rate_ca3*tau_m*tau_plus**2

    gamma_approx = np.exp(-delay/tau_plus)/(1+a*theta/b)

    # Bias current
    bias = -A/D

    biases[T] = bias
    gammas[T] = gamma_var
    lambdas[T] = lambda_var

figa = plt.figure()
plt.plot(alphas, np.transpose(list(biases.values())), label=biases.keys())
plt.title('CA1 place-tuned input', fontsize=fs)
plt.ylabel(r'$\rho^{bias}$', fontsize=fs)
plt.xlabel(r'$\theta$ / T', fontsize=fs)
leg = plt.legend(title='T', fontsize=fs)
leg.get_title().set_fontsize(fs)
plt.xticks(fontsize=fs)
plt.yticks(fontsize=fs)

figb = plt.figure()
plt.plot(alphas, np.transpose(list(gammas.values())), label=gammas.keys())
plt.title('Gamma', fontsize=fs)
plt.ylabel(r'$\gamma$', fontsize=fs)
plt.xlabel(r'$\theta$ / T', fontsize=fs)
leg = plt.legend(title='T', fontsize=fs)
leg.get_title().set_fontsize(fs)
plt.xticks(fontsize=fs)
plt.yticks(fontsize=fs)

figc = plt.figure()
plt.plot(alphas, np.transpose(list(lambdas.values())), label=lambdas.keys())
plt.title('Lambda', fontsize=fs)
plt.ylabel(r'$\lambda$', fontsize=fs)
plt.xlabel(r'$\theta$ / T', fontsize=fs)
leg = plt.legend(title='T', fontsize=fs)
leg.get_title().set_fontsize(fs)
plt.xticks(fontsize=fs)
plt.yticks(fontsize=fs)



#%%

A_pres = [-7, -9, -11]
biases = {}
gammas = {}
lambdas = {}

for A_pre in A_pres:

    alphas = np.arange(0,1,0.1)
    alphas[0] += 0.01

    A_plus= 1
    eta_stdp= 0.003 #0.002
    rate_ca3= 0.1
    step= 0.01
    tau_m= 2
    tau_plus= 60 #20
    N_post=1
    N_pre_tot=1
    N_pre=250
    eps0 = 1/N_pre

    # Total time in a state
    T = 100

    theta = alphas*T
    delay = (1-alphas)*T

    # Calculation for parameter A
    A1 = N_pre*rate_ca3*(1-np.exp(-theta/tau_m))*(theta-tau_plus*(1-np.exp(-theta/tau_plus)))
    # A1 = 1*rate_ca3*(1-np.exp(-theta/tau_m))*(theta-tau_plus*(1-np.exp(-theta/tau_plus)))
    A2 = theta/((tau_m+tau_plus))

    # Depression amplitude
    max_ltd = - A_plus*tau_m*tau_plus*(A1+A2)/theta
    # A_pre = -11 #-13 #max_ltd + 35/max_ltd # max_ltd - 15
    A_LTD = A_pre*rate_ca3*theta

    # Parameter A
    A = eta_stdp*(eps0*A_plus*rate_ca3*tau_m*tau_plus*(A1+A2) + A_LTD)
    # A = eta_stdp*(1*A_plus*rate_ca3*tau_m*tau_plus*(A1+A2) + A_LTD)

    # Parameter C
    C = eps0*eta_stdp*A_plus*rate_ca3*tau_plus*(np.exp(theta/tau_plus)-1)*N_pre*rate_ca3*tau_m*(1-np.exp(-theta/tau_m))*tau_plus*(1-np.exp(-theta/tau_plus))
    # C = 1*eta_stdp*A_plus*rate_ca3*tau_plus*(np.exp(theta/tau_plus)-1)*1*rate_ca3*tau_m*(1-np.exp(-theta/tau_m))*tau_plus*(1-np.exp(-theta/tau_plus))

    # Learning rate
    eta = -A

    # Lambda
    lambda_var = 1/(1+C/eta)

    # Gamma
    gamma_var = np.exp(-T/tau_plus)/lambda_var

    # Parameter D
    D = eta_stdp*rate_ca3*A_plus*tau_plus*(1-np.exp(-theta/tau_plus))*tau_plus*(1-np.exp(-(T-theta)/tau_plus))

    a = (A_plus*eps0*tau_m*tau_plus*(rate_ca3+1/(tau_plus+tau_m)) + A_pre)
    b = -1*A_plus*eps0*rate_ca3*tau_m*tau_plus**2

    gamma_approx = np.exp(-delay/tau_plus)/(1+a*theta/b)

    # Bias current
    bias = -A/D

    biases[A_pre] = bias
    gammas[A_pre] = gamma_var
    lambdas[A_pre] = lambda_var



figd = plt.figure()
plt.plot(alphas, np.transpose(list(biases.values())), label=biases.keys())
plt.title('CA1 place-tuned input', fontsize=fs)
plt.ylabel(r'$\rho^{bias}$', fontsize=fs)
plt.xlabel(r'$\theta$ / T', fontsize=fs)
leg = plt.legend(title=r'$A_{pre}$', fontsize=fs)
leg.get_title().set_fontsize(fs)
plt.xticks(fontsize=fs)
plt.yticks(fontsize=fs)

fige = plt.figure()
plt.plot(alphas, np.transpose(list(gammas.values())), label=gammas.keys())
plt.title('Gamma', fontsize=fs)
plt.ylabel(r'$\gamma$', fontsize=fs)
plt.xlabel(r'$\theta$ / T', fontsize=fs)
plt.ylim([0,1])
leg = plt.legend(title=r'$A_{pre}$', fontsize=fs)
leg.get_title().set_fontsize(fs)
plt.xticks(fontsize=fs)
plt.yticks(fontsize=fs)

figf = plt.figure()
plt.plot(alphas, np.transpose(list(lambdas.values())), label=lambdas.keys())
plt.title('Lambda', fontsize=fs)
plt.ylabel(r'$\lambda$', fontsize=fs)
plt.xlabel(r'$\theta$ / T', fontsize=fs)
leg = plt.legend(title=r'$A_{pre}$', fontsize=fs)
leg.get_title().set_fontsize(fs)
plt.xticks(fontsize=fs)
plt.yticks(fontsize=fs)



back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API