Run with Python:
pip-2.7 install cffi
PYTHON=python2.7 sh go.sh
Run with PyPy:
pip-pypy install cffi
PYTHON=pypy sh go.sh
import numpy as np | |
import numba as nb | |
from numba import types | |
from numba.extending import overload_method | |
@overload_method(types.Array, 'take') | |
def array_take(arr, indices): | |
if isinstance(indices, types.Array): |
#reference https://unix.stackexchange.com/questions/136371/how-to-download-a-folder-from-google-drive-using-terminal | |
#get cookie and code | |
wget --save-cookies cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/Code: \1\n/p' | |
#download the file | |
wget --load-cookies cookies.txt 'https://docs.google.com/uc?export=download&confirm=CODE_FROM_ABOVE&id=FILEID' |
import numpy as np | |
import sys, os | |
# Edit the paths as needed: | |
caffe_root = '../caffe/' | |
sys.path.insert(0, caffe_root + 'python') | |
import caffe | |
# Path to your combined net prototxt files: |
""" Radon Transform as described in Birkfellner, Wolfgang. Applied Medical Image Processing: A Basic Course. [p. 344] """ | |
from scipy import misc | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def discrete_radon_transform(image, steps): | |
R = np.zeros((steps, len(image)), dtype='float64') | |
for s in range(steps): | |
rotation = misc.imrotate(image, -s*180/steps).astype('float64') | |
R[:,s] = sum(rotation) |
Run with Python:
pip-2.7 install cffi
PYTHON=python2.7 sh go.sh
Run with PyPy:
pip-pypy install cffi
PYTHON=pypy sh go.sh
The fundamental unit in PyTorch is the Tensor. This post will serve as an overview for how we implement Tensors in PyTorch, such that the user can interact with it from the Python shell. In particular, we want to answer four main questions:
PyTorch defines a new package torch
. In this post we will consider the ._C
module. This module is known as an "extension module" - a Python module written in C. Such modules allow us to define new built-in object types (e.g. the Tensor
) and to call C/C++ functions.
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc. | |
Now on pip! `pip install arrgh` https://github.com/nmwsharp/arrgh |
#!/bin/bash | |
# install CUDA Toolkit v8.0 | |
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network)) | |
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb" | |
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG} | |
sudo dpkg -i ${CUDA_REPO_PKG} | |
sudo apt-get update | |
sudo apt-get -y install cuda |
from graphviz import Digraph | |
import torch | |
from torch.autograd import Variable, Function | |
def iter_graph(root, callback): | |
queue = [root] | |
seen = set() | |
while queue: | |
fn = queue.pop() | |
if fn in seen: |
# Steps to build and install tmux from source. | |
# Takes < 25 seconds on EC2 env [even on a low-end config instance]. | |
VERSION=2.7 | |
sudo yum -y remove tmux | |
sudo yum -y install wget tar libevent-devel ncurses-devel | |
wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz | |
tar xzf tmux-${VERSION}.tar.gz | |
rm -f tmux-${VERSION}.tar.gz | |
cd tmux-${VERSION} |