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
# modified from this: | |
# https://github.com/iaciac/py-draw-simplicial-complex/blob/master/Draw%202d%20simplicial%20complex.ipynb | |
from copy import copy | |
import networkx as nx | |
import itertools | |
import matplotlib.pyplot as plt | |
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
hey look here's me writing something |
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 numpy as np | |
from random import sample | |
# The Jaccard distance is truly a metric: https://arxiv.org/pdf/1612.02696.pdf | |
def jaccard_distance(set1: set, set2: set): | |
union_size = len(set1.union(set2)) | |
intersection_size = len(set1.intersection(set2)) | |
return 1 - (intersection_size / union_size) |
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 numpy as np | |
# Give me some random vectors | |
def random_vectors_generator(dimension=10, num_vectors=10): | |
for _ in range(num_vectors): | |
yield np.random.rand(dimension) | |
# Give me a random distance matrix |
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 torch | |
import matplotlib.pyplot as plt | |
def generate_basis(num_channels, height, width): | |
zero_tensor = torch.zeros((num_channels, height, width)) | |
for i in range(num_channels): | |
for j in range(height): | |
for k in range(width): | |
basis_element = torch.clone(zero_tensor) |
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 torch | |
import torchvision | |
import torchvision.transforms as transforms | |
import torch.optim as optim | |
import torch.nn as nn | |
import umap | |
import matplotlib.pyplot as plt | |
# Check whether GPU is available and define it as a device | |
is_gpu_available = torch.cuda.is_available() |
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 torch | |
import torchvision | |
import torchvision.transforms as transforms | |
import torch.optim as optim | |
import torch.nn as nn | |
import umap | |
import matplotlib.pyplot as plt | |
import json | |
trinity_template = { |
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 numpy as np | |
import torch | |
from datetime import datetime | |
if __name__ == '__main__': | |
num_dims = 3 | |
dim = 1024 | |
for _ in range(10): |
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 langchain.document_loaders import MastodonTootsLoader | |
from langchain.indexes import VectorstoreIndexCreator | |
from langchain.vectorstores.utils import filter_complex_metadata | |
loader = MastodonTootsLoader(mastodon_accounts=["@[email protected]"], number_toots=300) | |
documents = loader.load() | |
documents = filter_complex_metadata(documents) | |
index = VectorstoreIndexCreator().from_documents(documents) | |
print(index.query("What kinds of interests does this user have?")) |
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 langchain.document_loaders import OnlinePDFLoader | |
from langchain.indexes import VectorstoreIndexCreator | |
loader = OnlinePDFLoader("https://arxiv.org/pdf/1606.06353.pdf") | |
documents = loader.load() | |
index = VectorstoreIndexCreator().from_documents(documents) | |
print(index.query("What are the main results of this paper?")) |