Skip to content

Instantly share code, notes, and snippets.

View ricsi98's full-sized avatar

Richárd Kiss ricsi98

View GitHub Profile
@ricsi98
ricsi98 / TrainTestSplitGTSRBDataset.py
Created November 24, 2021 19:34
Splits the whole Final_Train GTSRB dataset into a train and test piece. Usage: `split_classes("./GTSRB/Final_Training/Images", "./train", "./test", 0.1)`
import os
import random
import pandas as pd
from shutil import copyfile
class DataSplitter:
def __init__(self, split_ratio):
@ricsi98
ricsi98 / lzw.py
Last active December 12, 2021 18:54
Lempel-Ziv-Welch algorithm in python
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
@ricsi98
ricsi98 / coinchange.py
Last active March 29, 2022 15:06
Efficient solution for the coin change problem in python
"""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
@ricsi98
ricsi98 / graph2gauss.py
Last active January 16, 2023 12:38
Graph2Gauss in PyTorch
"""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
@ricsi98
ricsi98 / poincare_karateclub.ipynb
Created May 5, 2023 20:22
Poincaré embeddings for the Karateclub graph
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ricsi98
ricsi98 / Solution.ipynb
Created October 31, 2023 16:13
Homework Assignment: Salary Classification
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ricsi98
ricsi98 / fb15k_mapping.py
Created April 28, 2024 14:29
Create Freebase ID to node index mapping for FB15k-237 dataset.
"""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")
@ricsi98
ricsi98 / main.ipynb
Last active June 27, 2024 20:41
Spectral Convolution on Graphs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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]