Skip to content

Instantly share code, notes, and snippets.

View qihongl's full-sized avatar
👋

Qihong Lu qihongl

👋
View GitHub Profile
@qihongl
qihongl / gist:dc039dfb1c65632df66e538393711f32
Created October 11, 2024 14:50
show that sparse connectivity decorrelate internal representations
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Parameters
input_size = 100 # Number of input neurons
output_size = 100 # Number of output neurons
num_samples = 1000 # Number of input samples
sparsity_levels = np.linspace(0.1, 1.0, 10) # Connectivity levels (from sparse to dense)
@qihongl
qihongl / walk-on-a-sphere.py
Created April 23, 2024 16:21
walk-on-a-sphere.py
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style='white', palette='colorblind', context='talk')
cpal = sns.color_palette('colorblind')
import numpy as np
import numpy as np
from scipy.linalg import qr
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style='white', palette='colorblind', context='talk')
cpal = sns.color_palette()
n_pts = 3
n_dim = 2 # number of hidden units in the simulation
@qihongl
qihongl / sgd-2d-plot
Created October 13, 2023 02:43
Simulated SGD trajectory - 2d contour plot
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style='white', palette='colorblind', context='talk')
np.random.seed(1)
# Define the function (error surface)
def f(x, y):
return x**2 + y**2 # Example of a simple quadratic error surface
@qihongl
qihongl / summary.sh
Created October 1, 2023 15:10
slurm - summary ongoing jobs
squeue -u qlu | awk '
BEGIN {
abbrev["R"]="(Running)"
abbrev["PD"]="(Pending)"
abbrev["CG"]="(Completing)"
abbrev["F"]="(Failed)"
}
NR>1 {a[$5]++}
END {
for (i in a) {
#!/bin/bash
exp_name=0916-widesim-prandom
n_epoch=1000
n_def_tps=0
enc_size=16
similarity_max=.9
similarity_min=0
p_rm_ob_enc=0.3
#!/bin/bash
#SBATCH -t 13:55:00
#SBATCH -c 1
#SBATCH --mem-per-cpu 4G
#SBATCH --job-name=lcarnn
#SBATCH --mail-type=FAIL
#SBATCH [email protected]
#SBATCH --output slurm_log/lcarnn-%j.log
@qihongl
qihongl / bp
Created December 5, 2019 04:01
bp
# general shortcuts
alias ls='ls -GFh'
alias l='ls -ltr'
alias f='open -a Finder ./'
alias cppath='pwd|pbcopy'
alias cdgit='cd /Users/Qihong/Dropbox/github'
alias cdnorman='cd /Volumes/norman/qlu'
# customize the terminal
export PS1="\[\033[36m\]\u\[\033[m\]@:\[\033[33;1m\]\W\[\033[m\]\$ "
@qihongl
qihongl / dabest-simple-demo.py
Created August 20, 2019 00:08
demo, python dabest
import numpy as np
import pandas as pd
import dabest
cond_means = {'control': 0, 'test': 2}
scale = 1
n_data = 64
data_dict = {
cond: np.random.normal(loc=cond_means[cond], scale=scale, size=(n_data,))
@qihongl
qihongl / emergentsetup.md
Created June 29, 2019 17:15 — forked from githubpsyche/emergentsetup.md
emergent setup guide

Installing emergent

simulationexample The current process for setting up the new emergent is distributed across several webpages and can be a bit confusing or even contradictory. This is an attempt to put it all in one place, potentially into simpler terms, and with troubleshooting tips informed by my own experience getting everything running.

Download Go

The first step to setting up emergent is to download Go. Pick your favored binary release here, download it, and run it. The MSI installers for Windows and Mac do all the work for you.

Test Your Go Installation

You might want to make sure you installed Go successfully. To do this:

  1. Head to your Go workspace directory. The MacOS package installer places the Go distribution to /usr/local/go while the Windows once places it at c:\Go.