Skip to content

Instantly share code, notes, and snippets.

import glob
import logging
import os
import numpy as np
import re
import soundfile
from numpy.lib.stride_tricks import as_strided
from maracas.maracas import asl_meter
from audio_tools import iterate_invert_spectrogram
import torch
from torch.autograd import Variable
import numpy as np
import pickle
import os
from glob import glob
from tqdm import tqdm
@jfsantos
jfsantos / error.log
Created April 11, 2017 16:24
Issue when compiling PyTorch on a crouton env (ASUS Chromebook Flip)
-- Build files have been written to: /home/jfsantos/pytorch/torch/lib/build/libshm
[ 50%] Built target torch_shm_manager
[ 75%] Building CXX object CMakeFiles/shm.dir/core.cpp.o
/home/jfsantos/pytorch/torch/lib/libshm/core.cpp:149:1: error: invalid conversion from 'void* (*)(void*, long int)' to 'void* (*)(void*, ptrdiff_t) {aka void* (*)(void*, int)}' [-fpermissive]
};
^
/home/jfsantos/pytorch/torch/lib/libshm/core.cpp:149:1: error: invalid conversion from 'void* (*)(void*, void*, long int)' to 'void* (*)(void*, void*, ptrdiff_t) {aka void* (*)(void*, void*, int)}' [-fpermissive]
CMakeFiles/shm.dir/build.make:62: recipe for target 'CMakeFiles/shm.dir/core.cpp.o' failed
make[2]: *** [CMakeFiles/shm.dir/core.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/shm.dir/all' failed
from __future__ import division
import multiprocessing
import scipy.spatial.distance
import numpy as np
import sklearn.datasets
from time import time
from multiprocessing import Pool
from itertools import combinations
def train_fn(model, optimizer, criterion, batch):
x, y, lengths = batch
x = Variable(x.cuda())
y = Variable(y.cuda(), requires_grad=False)
mask = Variable(torch.ByteTensor(x.size()).fill_(1).cuda(),
requires_grad=False)
for k, l in enumerate(lengths):
mask[:l, k, :] = 0
from torch.utils.data import Dataset
class DummyDataset(Dataset):
def __init__(self, items):
super(DummyDataset, self).__init__()
self.items = items
def __getitem__(self, index):
return self.items[index]
Agility
&{template:default} {{name=@{selected|character_name}}}{{Agility roll=[[1d20 + @{selected|agility_mod} + [[?{# Boons|0} - ?{# Banes|0}]]d6k1]]}}
Intellect
&{template:default} {{name=@{selected|character_name}}}{{Intellect roll=[[1d20 + @{selected|intellect_mod} + [[?{# Boons|0} - ?{# Banes|0}]]d6k1]]}}
Perception
'''
A logistic regression example using the meta-graph checkpointing
features of Tensorflow.
Author: João Felipe Santos, based on code by Aymeric Damien
(https://github.com/aymericdamien/TensorFlow-Examples/)
'''
from __future__ import print_function
@jfsantos
jfsantos / 0_reuse_code.js
Created November 29, 2016 00:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
from keras.models import Sequential
from keras.layers import Dense
from keras.utils.io_utils import HDF5Matrix
import numpy as np
def create_dataset():
import h5py
X = np.random.randn(200,10).astype('float32')
y = np.random.randint(0, 2, size=(200,1))
f = h5py.File('test.h5', 'w')