Skip to content

Instantly share code, notes, and snippets.

View gpleiss's full-sized avatar

Geoff Pleiss gpleiss

View GitHub Profile
@gpleiss
gpleiss / image_zip_dataset.py
Last active June 14, 2018 22:02
ImageZipDataset for PyTorch
import os
import csv
from zipfile import ZipFile
from contextlib import contextmanager
import torch
from PIL import Image
class _ImageZipDataset(torch.utils.data.Dataset):
@gpleiss
gpleiss / reliability_diagram.py
Created May 23, 2018 23:42
Reliability diagram code
import torch
import numpy as np
from matplotlib import pyplot as plt
def make_model_diagrams(outputs, labels, n_bins=10):
"""
outputs - a torch tensor (size n x num_classes) with the outputs from the final linear layer
- NOT the softmaxes
labels - a torch tensor (size n) with the labels
"""
import fs from 'fs-promise';
import DAG from 'dag-map';
import glob from 'glob';
import promisify from 'es6-promisify';
const promisedGlob = promisify(glob);
(async function() {
const dag = new DAG();
const allPackageFilePaths = await promisedGlob('**/node_modules/*/package.json');
@gpleiss
gpleiss / Matcher
Last active August 29, 2015 14:14
Example of Capybara `synchronize` in a matcher
def has_analytics_message?(msg)
document.synchronize do |variable|
gaq = evaluate_script('window._gaq')
raise Capybara::ElementNotFound, "#{msg} was not fired.\nActual analytics events triggered:\n\n#{gaq}" unless gaq.include?(msg)
end
true
end