Skip to content

Instantly share code, notes, and snippets.

View makdoudN's full-sized avatar
🏠
Working from home

Makdoud makdoudN

🏠
Working from home
View GitHub Profile
@omri374
omri374 / spacy_preprocessor.py
Created May 13, 2020 10:39
Text preprocessing using spaCy
import re
from typing import List
import spacy
from spacy.tokens import Doc
from tqdm import tqdm
class SpacyPreprocessor:
def __init__(
@MaggieAppleton
MaggieAppleton / roam-light-theme.css
Last active August 31, 2022 04:41
Roam Light Theme with Custom Data Tags
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "TT Commons", sans-serif;
font-size: 3em;
}
div,
@pierrelux
pierrelux / discount.py
Last active April 24, 2021 06:59
Four ways to compute discounted returns
import numpy as onp
from scipy.signal import lfilter
import jax
import jax.numpy as jnp
def discount_lfilter(rewards, discount):
return lfilter(b=[1], a=[1, -discount], x=rewards[::-1])[::-1]
def discount_correlate(rewards, discount):
@petsto
petsto / Homebrew Install Top Google Fonts.md
Last active April 8, 2025 18:35
Quickly install top Google fonts and then some via Homebrew

List of some top fonts for easy terminal install via Homebrew Fonts Cask.

brew install font-open-sans &&
brew install font-noto-sans &&
brew install font-roboto && brew install font-roboto-mono && brew install font-roboto-slab
brew install font-montserrat &&
brew install font-lato &&
brew install font-fira-code &&
brew install font-source-code-pro &&
@pierrelux
pierrelux / accumulate_discounted.py
Created July 19, 2019 17:59
VJP through a specific lfilter performing discounting on an array of scalar elements (rewards).
import autograd.numpy as np
from scipy.signal import lfilter
from autograd.extend import primitive, defvjp
@primitive
def accumulate_discounted(rewards, discount=1.):
"""Behaves like `accumulate` but where each array element gets discounted.
Args:
rewards (np.ndarray): 1D array of rewards
discount (float): Scalar discount factor
@pierrelux
pierrelux / exact_pg.py
Created July 17, 2019 21:28
Exact Policy Gradient in jax, demonstrated in figure 2d of Dadashi et al. (2019)
import jax
import jax.numpy as np
from jax import grad, jit
from jax.scipy.special import logsumexp
def dadashi_fig2d():
""" Figure 2 d) of
''The Value Function Polytope in Reinforcement Learning''
by Dadashi et al. (2019) https://arxiv.org/abs/1901.11524
@SkafteNicki
SkafteNicki / MixtureSameFamily.py
Created July 10, 2019 05:56
Implementation of mixture models in pytorch
import torch
from torch import distributions as D
from torch.nn import functional as F
class MixtureSameFamily(D.Distribution):
""" Mixture (same-family) distribution.
The `MixtureSameFamily` distribution implements a (batch of) mixture
distribution where all components are from different parameterizations of
@victorbruce
victorbruce / Firebase.md
Last active January 12, 2025 18:31
My journey with Firebase so far. Cheatsheet to serve as a quick reference when developing firebase applications

Firebase

Set up firebase and Deploy

  • Head over to firebase. Sign in and create a project.

  • Copy your project settings under Firebase SDK snippet into your local project (ie your project's api key, auth domain, databaseURL, etc)

  • Create a file (firebase.js or config.js Any name that suits you is fine)

@jesseengel
jesseengel / wav2tfrecord.py
Created June 12, 2019 19:25
Wav2TFRecord
from cStringIO import StringIO
import os
import numpy as np
import scipy.io.wavfile
import tensorflow as tf
output_path = os.path.expanduser('~/Desktop/test.tfrecord')
sample_path = os.path.expanduser('~/Desktop/test.wav')
import numpy as np
import faiss
def search_knn(xq, xb, k, distance_type=faiss.METRIC_L2):
""" wrapper around the faiss knn functions without index """
nq, d = xq.shape
nb, d2 = xb.shape
assert d == d2