Skip to content

Instantly share code, notes, and snippets.

Avatar

KARAN PATHAK karanpathak

View GitHub Profile
View joblib_cache_memmap_func.py
# Create a new cache directory
cache_dir2 = "<path-to-your-directory>/sample_cache_dir2"
memory2 = Memory(cache_dir2, mmap_mode='c')
# Pass function to Memory.cache
@memory2.cache(verbose=0)
def func_memmap(x):
print("Example of Computationally intensive function!")
print("The result is not cached for this particular input")
View joblib_cache_func.py
# Define our function
def func(x):
print("Example of Computationally intensive function!")
print("The result is not cached for this particular input")
sleep(4.0)
return np.square(x)
# Pass it to Memory.cache method
func_mem = mem.cache(func, verbose=0)
View joblib_cache_func_decorator.py
@mem.cache(verbose=0)
def func_as_decorator(x):
print("Example of Computationally intensive function!")
print("The result is not cached for this particular input")
sleep(4.0)
return np.square(x)
View joblib_cache_define_large_input.py
input1 = np.vander(np.arange(10**4)).astype(np.float)
input2 = np.vander(np.random.uniform(low=0,high=10**5, size=5000))
print("Shape of input1: ",input1.shape)
print("Shape of input2: ",input2.shape)
View joblib_cache_import_initialize.py
# Import the Memory class from joblib
from joblib import Memory
# Create your cache directory
cache_dir="<path-to-your-directory>/sample_cache_dir"
# Create a memory object
mem = Memory(cache_dir)
View install-opencv-2.4.11-in-ubuntu.sh
# install dependencies
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev
You can’t perform that action at this time.