Skip to content

Instantly share code, notes, and snippets.

View mlgill's full-sized avatar

Michelle Gill mlgill

View GitHub Profile
@LouisFaure
LouisFaure / gpu_wrappers.py
Last active January 19, 2024 17:22
some GPU accelerated function for scanpy
import scanpy as sc
import cupy as cp
from scipy.sparse import csr_matrix, find, issparse
from scipy.sparse.linalg import eigs
import numpy as np
import pandas as pd
import cudf
import glob
from cupy.sparse import cupyx as cpx
from cupyx.scipy.sparse import coo_matrix as coo_matrix_gpu
@kashif
kashif / amsgrad.py
Last active May 13, 2019 14:21
Keras implementation of AMSGrad optimizer from "On the Convergence of Adam and Beyond" paper
class AMSgrad(Optimizer):
"""AMSGrad optimizer.
Default parameters follow those provided in the Adam paper.
# Arguments
lr: float >= 0. Learning rate.
beta_1: float, 0 < beta < 1. Generally close to 1.
beta_2: float, 0 < beta < 1. Generally close to 1.
epsilon: float >= 0. Fuzz factor.
@timvieira
timvieira / simple-backprop.py
Last active May 14, 2022 04:32
Simple example of manually performing "automatic" differentiation.
"""
Simple example of manually performing "automatic" differentiation
"""
import numpy as np
from numpy import exp, sin, cos
def f(x, with_grad=False):
# Need to cache intermediates from forward pass (might not use all of them).
a = exp(x)
@nguyendv
nguyendv / boto3_tutorial.py
Created June 30, 2017 20:36
Boto3 tutorial: create a vpc, a security group, a subnet, an instance on that subnet, then make that instance 'pingable' from Internet
import boto3
# http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#service-resource
ec2 = boto3.resource('ec2', aws_access_key_id='AWS_ACCESS_KEY_ID',
aws_secret_access_key='AWS_SECRET_ACCESS_KEY',
region_name='us-west-2')
# create VPC
vpc = ec2.create_vpc(CidrBlock='192.168.0.0/16')
@tarokiritani
tarokiritani / jupyter_collapse_headings_html
Created January 22, 2017 12:51
small script to collapse headings in jupyter notebook after converted to html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
var all_cells = $("div.cell");
$.each(all_cells, function( index, value ) {
if ($(value).find("h1").length == 0){
$(value).hide()
} else{
var bare_h1 = $(value).find("h1").text()
@toonetown
toonetown / shimo-pulse-vpn
Last active February 14, 2023 14:20
Leverages ssh and openconnect to connect Shimo to PulseSecure hosts
#!/bin/bash
: ${NUM_FAILURES_ALLOWED:=10}
: ${SLEEP_PING_TIME:=10}
if [ "${1}" == "-c" -a -n "${2}" ]; then SHIMO_SCRIPT_CFG="${2}"; shift 2; fi
if [ -n "${SHIMO_SCRIPT_CFG}" ]; then
: ${SHIMO_HOME:="${HOME}/Library/Application Support/Shimo"}
: ${SHIMO_SCRIPT_HOME:="${SHIMO_HOME}/Scripts"}
: ${SHIMO_CONFIG_DIR:="${SHIMO_SCRIPT_HOME}/${SHIMO_SCRIPT_CFG}"}
@fperez
fperez / SimpleNeuralNets.ipynb
Last active April 19, 2022 18:52
Notes for "Why does deep and cheap learning work so well?" (ArXiv:1608.08225v1/cond-mat.dis-nn) by Lin and Tegmark.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@betatim
betatim / convert.sh
Last active August 22, 2021 23:20
🚀 Minimal `nbconvert` template to convert jupyter notebooks to HTML + thebe (details: https://betatim.github.io/posts/really-interactive-posts/). Open the generated HTML in a browser it will look like a normal notebook except for the code cells, which you can edit and execute!
# Convert your notebook to an interactive webpage
#
# Attached a notebook (really-interactive-posts.ipynb) and the generated
# output (really-interactive-posts.html). The thebe.tpl template file is
# at the very end of the gist.
$ jupyter nbconvert --template thebe.tpl --to html <notebook.ipynb>
# You can open the generated webpage locally file://... howerver some
@karpathy
karpathy / min-char-rnn.py
Last active May 9, 2024 14:16
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@jiffyclub
jiffyclub / tserv
Last active September 3, 2020 09:14
Start a Tornado static file server in a given directory. To start the server in the current directory: `tserv .`. Then go to `http://localhost:8000` to browse the directory.
#!/usr/bin/env python
"""
Starts a Tornado static file server in a given directory.
To start the server in the current directory:
tserv .
Then go to http://localhost:8000 to browse the directory.
Use the --prefix option to add a prefix to the served URL,