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 Literal | |
import numpy as np | |
import scipy | |
from scipy.sparse import csr_array | |
from torch_geometric.datasets import Planetoid | |
from torch_geometric.utils import to_scipy_sparse_matrix | |
NormType = Literal["sym", "row", None] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
"""Create Freebase ID to node index mapping for FB15k-237 dataset.""" | |
import json | |
from pathlib import Path | |
from typing import Dict | |
from torch_geometric.datasets import FB15k_237 | |
NODE_PATH = Path("nodes.json") | |
EDGE_PATH = Path("edges.json") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
"""PyTorch implementation of the Graph2Gauss algorithm (https://arxiv.org/pdf/1707.03815.pdf)""" | |
import walker | |
import random | |
import numpy as np | |
import networkx as nx | |
import torch | |
from torch.nn import Linear, Module, Sequential, ReLU |
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
"""Find all number of combinations that formed a sum (N) amount with given denominations (A)""" | |
"""The combinations can be indexed with I and for the same I the same permutation is returned every time""" | |
from typing import List, Dict, Set, Tuple | |
from tqdm import tqdm | |
import sys | |
MAX_CACHE_SIZE = 1000000 | |
USE_PRUNE = True |
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 Dict, List | |
def match_length(data: bytearray, ptr: int, word: bytearray): | |
offset = 0 | |
while offset < len(word) and offset + ptr < len(data): | |
if data[ptr + offset] != word[offset]: break | |
offset += 1 | |
return offset |
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 os | |
import random | |
import pandas as pd | |
from shutil import copyfile | |
class DataSplitter: | |
def __init__(self, split_ratio): |