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
-- Recursively show layer output tensor sizes in a Torch model. | |
require 'nn' | |
require 'torch' | |
function join(list, sep) | |
local sep = sep or ' ' | |
return table.concat(list, sep) | |
end |
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 python | |
""" | |
Display a grid of thumbnails. | |
""" | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.axes_grid1 import ImageGrid | |
import numpy as np | |
import PIL |
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
-- Use the class rock to create a Dataset class | |
-- that can be used by nn.StochasticGradient in Torch | |
local class = require 'class' | |
local Dataset = class('Dataset') | |
function Dataset:__init(inputs, labels) | |
self.inputs = inputs | |
self.labels = labels | |
end |
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 python | |
""" | |
CUSOLVER getrf demo. | |
""" | |
import numpy as np | |
import scipy.linalg | |
import scipy as sp | |
import pycuda.autoinit |
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 networkx as nx | |
def partly_relabel_by_sorted_attr(g_old, select_attr, select_attr_vals, sort_attr): | |
""" | |
Relabel nodes of NetworkX graph such that the new IDs are | |
sorted according to the order of some attribute such that | |
only the nodes that have that attribute are relabeled. | |
Parameters | |
---------- |
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 python | |
""" | |
Simple demo of how to use scikit-cuda with multiprocessing. | |
""" | |
import atexit | |
import multiprocessing as mp | |
import numpy as np |
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 python | |
""" | |
Define and use custom step in Gremlin via pyorient. | |
""" | |
from pyorient.ogm import Graph, Config | |
from pyorient.ogm.declarative import declarative_node, declarative_relationship | |
from pyorient.ogm.property import String |
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 python | |
""" | |
Demo of how to asynchronously pass GPU memory managed by pycuda to mpi4py. | |
Notes | |
----- | |
This code can be used to perform peer-to-peer communication of data via | |
NVIDIA's GPUDirect technology if mpi4py has been built against a | |
CUDA-enabled MPI implementation such as MVAPICH2 or OpenMPI. |
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 python | |
""" | |
Find permutation of matrix that maximizes its trace using the Munkres algorithm. | |
Reference | |
--------- | |
https://stat.ethz.ch/pipermail/r-help/2010-April/236664.html | |
""" |
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 python | |
""" | |
Python functions for finding open files and PIDs that have opened a file. | |
""" | |
import numbers | |
import subprocess | |
try: |