Skip to content

Instantly share code, notes, and snippets.

View KyleOng's full-sized avatar
🎯
Focusing

Kyle KyleOng

🎯
Focusing
  • Malaysia
View GitHub Profile
{
"_start": 2019,
"_end": 2021,
"_citation": null,
"_mdate": 1625056932.691998,
"_json": {
"abstract-citations-response": {
"h-index": "1",
"identifier-legend": {
"identifier": [
@KyleOng
KyleOng / sparse_dataloader.py
Created April 8, 2021 06:59
Pytorch dataloader for sparse tensor
from typing import Union
import numpy as np
import torch
from torch.utils.data import Dataset, DataLoader
from scipy.sparse import (random,
coo_matrix,
csr_matrix,
vstack)
from tqdm import tqdm
@KyleOng
KyleOng / gmplot.r
Created November 24, 2020 08:13
Gaussian Mixture plot in R
library(ggplot2)
gg.mixEM <- function(EM) {
require(ggplot2)
x <- with(EM,seq(min(x)-1,max(x)+1,len=1000))
pars <- with(EM,data.frame(comp=colnames(posterior), mu, sigma,lambda))
em.df <- data.frame(x=rep(x,each=nrow(pars)),pars)
em.df$y <- with(em.df,lambda*dnorm(x,mean=mu,sd=sigma))
ggplot(data.frame(x=EM$x),aes(x,y=..density..)) +
geom_histogram(fill=NA,color="black",bins=41)+