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
# 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") |
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
# 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) |
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
@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) |
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
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) |
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 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) |
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
# 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 | |