Skip to content

Instantly share code, notes, and snippets.

View kasperjunge's full-sized avatar

Kasper Junge kasperjunge

View GitHub Profile
@kasperjunge
kasperjunge / flatten_list.py
Last active July 29, 2022 11:04
Flatten list
from typing import List, Any
def flatten_list(list_of_lists: List[List[Any]]) -> List[Any]:
"""Merge/flatten a list of lists into one single list.
Example: [[1, 2, 3],[4, 5, 6]] --> [1, 2, 3, 4, 5, 6]
Args:
list_of_lists (List[list]): List of lists to be merged/flattened.
Returns:
@kasperjunge
kasperjunge / download_n_eb_articles.py
Created July 26, 2022 07:19
Download n Ekstra Bladet new articles from the Danish mC4 dataset.
import pandas as pd
from tqdm import tqdm
from datasets import load_dataset
def download_n_eb_articles(n: int) -> pd.DataFrame:
"""Extract n Ekstra Bladet articles from the Danish subset
of the mC4 dataset.
Args:
n (int): Number of articles to extract.
Returns:
@endolith
endolith / DFT_ANN.py
Last active April 25, 2024 07:42
Training neural network to implement discrete Fourier transform (DFT/FFT)
"""
Train a neural network to implement the discrete Fourier transform
"""
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
import numpy as np
import matplotlib.pyplot as plt
N = 32
batch = 10000