This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'optparse' | |
OPTIONS = {} | |
PARSER = OptionParser.new do |opts| | |
opts.banner = "Usage: #{$0} [OPTIONS] INPUT_FILE [HOTKEY OUTPUT_FILE]..." | |
opts.separator(<<END | |
#{$0} -- ultra-basic console-based multiclass text annotation tool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy.lib.stride_tricks import as_strided | |
def ngrams_via_striding(array, order): | |
itemsize = array.itemsize | |
assert array.strides == (itemsize,) | |
return as_strided(array, (max(array.size + 1 - order, 0), order), (itemsize, itemsize)) | |
In [71]: a = numpy.arange(10) | |
In [72]: ngrams_via_striding(a, 4) | |
Out[72]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class iterable(object): | |
"""Decorates a generator function (or any other iterator-returning | |
function) as something which implements the iterable protocol and | |
can be safely passed to other code which may iterate over it | |
multiple times. | |
Usage: | |
@iterable | |
def foo(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import theano.tensor as T | |
import theano | |
import numpy as np | |
import gc | |
def freemem(): | |
gc.collect() | |
gc.collect() | |
gc.collect() | |
return theano.sandbox.cuda.cuda_ndarray.cuda_ndarray.mem_info()[0] / 1024**2 |
OlderNewer