Skip to content

Instantly share code, notes, and snippets.

Avatar

João Felipe Santos jfsantos

View GitHub Profile
View audio_utils.py
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
View train_loop.py
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 Apr 11, 2017
Issue when compiling PyTorch on a crouton env (ASUS Chromebook Flip)
View error.log
-- 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
View pairwise_distance.py
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
View pytorch_train_with_masking.py
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
View dummy_dataset.py
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]
View gist:c0f3f4cd5c76dfc5f1ba8310a821c2d5
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
View logistic_regression_with_checkpointing.py
'''
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 Nov 29, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View example_hdf5matrix.py
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')
You can’t perform that action at this time.