This file contains 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 numpy as np | |
import pandas as pd | |
from typing import List | |
from time import time | |
from multiprocessing import Pool | |
from multiprocessing import shared_memory | |
from multiprocessing.shared_memory import SharedMemory | |
print("--Shared Memory--") |
This file contains 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 numpy as np | |
from typing import List | |
from time import time | |
from multiprocessing import Pool | |
print("--No shared memory---") | |
M = 100000 | |
d = 32 | |
N = 1000 |
This file contains 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 typing import List | |
import faiss | |
import numpy as np | |
from numba import jit | |
from numba.typed import List | |
from scipy.spatial.distance import cdist | |
def numpy_cosine_batch_nn(matrix: np.array, queries: List[np.array]): |
This file contains 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 numpy as np | |
class CustomKMeans: | |
def __init__(self, k, centroids, X): | |
''' | |
k: number of clusters | |
centroids: initial value of centres. | |
np.array of shape (k, n_features) | |
X: dataset of m points and n_features. | |
array of shape (m, n_features) |