Skip to content

Instantly share code, notes, and snippets.

View PCJohn's full-sized avatar

Prithvijit Chakrabarty PCJohn

View GitHub Profile
@PCJohn
PCJohn / setup.sh
Last active January 13, 2023 22:37
wget https://gist.githubusercontent.com/PCJohn/ccbac70608f44f8c8d18cc4c89f3ab90/raw/8853e386321c61d4b0b6ac58db1bc4ac457574e0/vimrc
mv vimrc ~/.vimrc
bash
# Following: https://askubuntu.com/questions/284957/vi-getting-multiple-sorry-the-command-is-not-available-in-this-version-af
sudo apt-get install vim-gui-common
sudo apt-get install vim-runtime
# Use the Vundle vim plugin manager
# See: https://pseudoscripter.wordpress.com/2020/04/26/install-black-on-vim/
@PCJohn
PCJohn / memory_list.txt
Last active June 14, 2020 15:56
List of pages for memory
The rational analysis of memory: http://gershmanlab.webfactional.com/pubs/RationalAnalysisOfMemory.pdf
Rate distortion trade-off in human memory: https://ccneuro.org/2019/proceedings/0000369.pdf
Convolutional Neural Associative Memories: https://arxiv.org/pdf/1407.6513.pdf
Holographic Reduced Representation: https://www.amazon.com/dp/B0188Y14VS/ref=dp-kindle-redirect?_encoding=UTF8&btkr=1
@PCJohn
PCJohn / kalman.py
Created June 6, 2020 21:03
Simple Kalman Filter
import os
import cv2
import time
import numpy as np
from matplotlib import pyplot as plt
size = 1000
im = np.ones((size,size,3))
def plot(p,sz=3,col=(0,255,0)):
"""
Usage:
srun -p 1080ti-short --mem 100000 --gres=gpu:1 \
python tools/viz_net.py --dataset coco2017 --output_dir tmp \
--cfg configs/context/self-attn/e2e_faster_rcnn_R-50-C4_1x_attn_head-8_lr-long-v3.yaml \
--ckpt data/models/coco-visual-8-head/model_step69999.pth
Example (8 heads v3 on COCO):
srun -p 1080ti-short --gres=gpu:1 --mem 20000 python tools/viz_net.py \
@PCJohn
PCJohn / graph.py
Created January 14, 2019 07:28
Display graphs with networkx
from __future__ import division
import numpy as np
from matplotlib import pyplot as plt
import networkx as nx
import copy
class Graph:
def __init__(self,adj,labels):
self.adj = adj
self.char_list = labels
@PCJohn
PCJohn / convdiv.py
Created July 20, 2017 05:06
This script tries to overfit a small convolutional network, to perform integer division
"""
Attempt to perform integer division by overfitting convolution layers
Input: 2 numbers A and C
Output: Integer B such that A.B = C
Author: Prithvijit Chakrabarty (prithvichakra@gmail.com)
"""
import random
@PCJohn
PCJohn / matfact.py
Created June 26, 2017 16:30
NNMF by overfitting neural networks
"""
Attempt to run NNMF (Non-negative matrix factorization) for integer matrices by overfitting with a high learning rate on backpropagation.
Try to factorize matrices: Find a matrix A such that xA = y for given matrices (x,y)
Author: Prithvijit Chakrabarty (prithvichakra@gmail.com)
"""
import random
import numpy as np
import tensorflow as tf
@PCJohn
PCJohn / Sieve.cpp
Last active September 17, 2015 07:04
An efficient sieve to factorize numbers
/*
This is memory saving sieve that efficiently factorizes integers below an upper limit.
It generates a structure that stores the smallest prime factor of all numbers below the limit.
Given a number, it divides it by the smallest prime factor and adds the factor to the list of factors. This is repeated till the number is reduced to 1.
Bitwise operations are used to save memory while storing the sieve encoded in a list of integers.
Author: Prithvijit Chakrabarty (prithvichakra@gmail.com)
*/
#include <vector>
@PCJohn
PCJohn / ClosedSurfaceFinder.java
Created September 17, 2015 06:13
Finding closed boundaries
/*Java source to find closed boundaries an array of binary pixels.
Author: Prithvijit Chakrabarty (prithvichakra@gmail.com)
*/
package projectjava;
import java.awt.Color;
public class ClosedSurfaceFinder {
@PCJohn
PCJohn / ConnectFour.java
Last active November 30, 2020 14:37
A Java text based game for Connect Four
/*Java source for a simple, text based game of Connect Four. Change the package name as required.
Players must enter a number between 0 and 7 (both inclusive) to specify the column in which he/she wants to drop his/her chip.
Author: Prithvijit Chakrabarty (prithvichakra@gmail.com)*/
package projectjava;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;