This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}"} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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, |
NewerOlder