Skip to content

Instantly share code, notes, and snippets.

View kirarpit's full-sized avatar
🤗

Arpit Garg kirarpit

🤗
View GitHub Profile
source ~/.git-prompt.sh
# bash prompt
export THIN_WHITE="\033[0;00m"
export BLACK="\033[0;30m"
export RED="\033[0;31m"
export GREEN="\033[0;32m"
export YELLOW="\033[0;33m"
export BLUE="\033[0;34m"
export GREY="\033[1;34m"
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@kirarpit
kirarpit / -shared-central-vs-local-emnist.ipynb
Created March 15, 2022 20:01
[SHARED] Central vs Local EMNIST
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def root(x, n):
if n == 1:
return x
if x == 1:
return x
high = x if x > 1 else 1
low = 0
mid = (high+low)/2
@kirarpit
kirarpit / covariance_and_correlation_matrix.py
Last active February 26, 2020 21:25
Reproduction of NumPy's covariance and correlation matrices from scratch in Python
import numpy as np
def covariance(X):
"""
Computes the covariance matrix of X
:param X: Input data of shape (N, M) where N is the
number of samples and M is the number of
features
:return: Output data of shape (M, M) where Output[i][j]
is Cov(feature_i, feature_j)
@kirarpit
kirarpit / robbie_ppo_rllib.py
Last active June 17, 2019 06:35
Robbie the soda-can-collecting robot (https://bit.ly/2MPUku5) trained with a deep RL algorithm, PPO, with the help of Ray RLlib.
import ray
from gym import spaces
from ray.rllib.env.multi_agent_env import MultiAgentEnv
import numpy as np
from ray.tune.registry import register_env
from ray.rllib.agents.registry import get_agent_class
from ray.rllib.rollout import rollout
import time
from ray import tune
@kirarpit
kirarpit / dgemm_row.lisp
Created April 22, 2019 20:49
A naive implementation of row-major double precision floating point general matrix multiplication (DGEMM) in Common Lisp.
;; row major matrix multiplication
(defun row_major_mm (a b c)
(flet (
(col (mat i) (mapcar #'(lambda (row) (elt row i)) mat))
(row (mat i) (elt mat i))
)
(loop for k from 0 below (length (row a 0))
do (loop for i from 0 below (length a)
do (let ((temp (elt (elt a i) k)))
@kirarpit
kirarpit / online_gradient_descent.py
Created December 3, 2018 07:47
Online gradient descent algorithm for portfolio management
import csv
import numpy as np
import matplotlib.pyplot as plt
def read_file(filename):
lines = []
csvreader = csv.reader(open(filename))
for line in csvreader:
lines.append(line)
@kirarpit
kirarpit / skiplist.py
Last active September 25, 2018 05:07
A simple implementation of skiplist which keeps track of median of the elements inserted.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 23 12:28:46 2018
@author: Arpit
"""
import random
'''
package c4;
import java.io.IOException;
import openingBook.Book;
import openingBook.BookSum;
import java.util.Scanner;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;