Skip to content

Instantly share code, notes, and snippets.

View authman's full-sized avatar

authman

View GitHub Profile
import math
from torch.optim.optimizer import Optimizer
# This version of Adam keeps an fp32 copy of the parameters and
# does all of the parameter updates in fp32, while still doing the
# forwards and backwards passes using fp16 (i.e. fp16 copies of the
# parameters and fp16 activations).
#
# Note that this calls .float().cuda() on the params such that it
# moves them to gpu 0--if you're using a different GPU or want to
import math
from torch.optim.optimizer import Optimizer
# This version of Adam keeps an fp32 copy of the parameters and
# does all of the parameter updates in fp32, while still doing the
# forwards and backwards passes using fp16 (i.e. fp16 copies of the
# parameters and fp16 activations).
#
# Note that this calls .float().cuda() on the params such that it
# moves them to gpu 0--if you're using a different GPU or want to
@authman
authman / shape_index.py
Created April 24, 2017 03:26 — forked from davecg/shape_index.py
Calculate 3D shape index using PyTorch
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision
import torchvision.transforms as transforms
import numpy as np
@authman
authman / region_growing.py
Last active March 24, 2017 23:43
Thresholded Region Growing (3D Flood Fill)
import numpy as np
# start_point = (1,2,3) # Z, X, Y coordinate values
def region_grow(vol, mask, start_point, epsilon=5, HU_mid=0, HU_range=0, fill_with=1):
sizez = vol.shape[0] - 1
sizex = vol.shape[1] - 1
sizey = vol.shape[2] - 1
@authman
authman / cache.js
Last active August 29, 2015 14:21 — forked from bshamric/cache.js
var fs = require('fs');
//this is the path that QTNetwork classes uses for caching files for it's http client
//the path should be the one that has 16 folders labeled 0,1,2,3,...,F
exports.cachePath = '/path/to/phantomjs/cache/data/folder';
//this is the extension used for files in the cache path
exports.cacheExtension = "d";
//the resources that are to be saved