Skip to content

Instantly share code, notes, and snippets.

View kmkurn's full-sized avatar
💭
I may be slow to respond.

Kemal Kurniawan kmkurn

💭
I may be slow to respond.
View GitHub Profile
@kmkurn
kmkurn / shrink_metrics.py
Created June 23, 2020 06:36
Shrink metrics values in a Sacred MongoDB database.
#!/usr/bin/env python
# Copyright 2020 Kemal Kurniawan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@kmkurn
kmkurn / matrix_tree.py
Last active June 23, 2020 06:37
Matrix-Tree theorem in PyTorch.
# Copyright 2020 Kemal Kurniawan
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@kmkurn
kmkurn / zipf-kompas.ipynb
Created January 5, 2019 23:49
Zipf's law in Kompas corpus.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kmkurn
kmkurn / bptt.ipynb
Last active December 15, 2018 13:05
Backpropagation Through Time (BPTT) tutorial
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kmkurn
kmkurn / compress_all.py
Created July 3, 2016 04:34
Compress all directories to a .tar.gz file
#!/usr/bin/env python
import argparse
import os
import subprocess
import tarfile
"""
This scipt compresses all directories inside a root directory to a
.tar.gz file. This script should be run with Python 3 in a machine
@kmkurn
kmkurn / append_movie_year.py
Created May 29, 2016 17:19
Python script to append movie release year to the movie directory name
#!/usr/bin/env python
"""
This script renames all directories in the format "<movie name>" to
"<movie name> (<year>)". The year is fetched from IMDb. The root of movie
directories to be renamed is assumed to be stored in MOVIES_DIR environment
variable.
This script is meant to be run with Python 2. IMDbPY needs to be installed.
@kmkurn
kmkurn / BFS.hs
Last active June 18, 2022 10:06
BFS in Haskell
{-# OPTIONS_GHC -Wall #-}
module BFS where
import Control.Monad (guard)
type Node = String
type Edge = (Node, Node)
@kmkurn
kmkurn / mpi_mm.c
Last active January 4, 2023 02:32
Matrix multiplication with MPI
/******************************************************************************
* FILE: mpi_mm.c
* DESCRIPTION:
* MPI Matrix Multiply - C Version
* In this code, the master task distributes a matrix multiply
* operation to numtasks-1 worker tasks.
* NOTE: C and Fortran versions of this code differ because of the way
* arrays are stored/passed. C arrays are row-major order but Fortran
* arrays are column-major order.
* AUTHOR: Blaise Barney. Adapted from Ros Leibensperger, Cornell Theory
@kmkurn
kmkurn / gaussian_huber.py
Created June 16, 2014 08:34
Simple Gaussian kernel model with Huber learning.
#!/usr/bin/python2
from __future__ import division
from __future__ import print_function
import itertools as it
import cvxpy as cvx
import matplotlib.pyplot as plt
import numpy as np
@kmkurn
kmkurn / gaussian_cls.py
Created June 16, 2014 08:33
Simple Gaussian kernel model with L1-CLS and QCLS.
#!/usr/bin/python2
from __future__ import division
from __future__ import print_function
import itertools as it
import cvxpy as cvx
import matplotlib.pyplot as plt
import numpy as np