Skip to content

Instantly share code, notes, and snippets.

View hamaadshah's full-sized avatar
:octocat:

Hamaad Shah hamaadshah

:octocat:
View GitHub Profile
@CMCDragonkai
CMCDragonkai / lorenz_curve_gini_coefficient.py
Last active November 1, 2023 09:50
Lorenz Curve and Gini Coefficient #python
import numpy as np
import matplotlib.pyplot as plt
# ensure your arr is sorted from lowest to highest values first!
arr = np.array([1,4,6,9,100])
def gini(arr):
count = arr.size
coefficient = 2 / count
indexes = np.arange(1, count + 1)
@redknightlois
redknightlois / ralamb.py
Last active August 9, 2023 20:50
Ralamb optimizer (RAdam + LARS trick)
class Ralamb(Optimizer):
def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0):
defaults = dict(lr=lr, betas=betas, eps=eps, weight_decay=weight_decay)
self.buffer = [[None, None, None] for ind in range(10)]
super(Ralamb, self).__init__(params, defaults)
def __setstate__(self, state):
super(Ralamb, self).__setstate__(state)
@iiSeymour
iiSeymour / benchmark_separable_convs.py
Last active March 3, 2023 02:29
Compare 1D Separable Convolutions in PyTorch and Tensorflow
#!/usr/bin/env python
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import sys
import torch
import numpy as np
import tensorflow as tf
from time import perf_counter
@jitsejan
jitsejan / Dockerfile
Last active April 9, 2024 11:15
PySpark, Docker and S3
FROM jupyter/pyspark-notebook
USER root
# Add essential packages
RUN apt-get update && apt-get install -y build-essential curl git gnupg2 nano apt-transport-https software-properties-common
# Set locale
RUN apt-get update && apt-get install -y locales \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
# Add config to Jupyter notebook
COPY jupyter/jupyter_notebook_config.py /home/jovyan/.jupyter/
@rodgtr1
rodgtr1 / awsCLIAutomation.sh
Created July 2, 2021 14:13
Script to authenticate with AWS CLI with MFA token
#!/bin/bash
set -e
# specify your MFA_DEVICE_ARN
MFA_DEVICE_ARN=YOURMFAARN
PATH_TO_CREDENTIALS_FILE=/path/to/.aws/credentials
echo $PATH_TO_CREDENTIALS_FILE
#1H = 3600
#2H = 7200
#3H = 10800