Skip to content

Instantly share code, notes, and snippets.

View wiseodd's full-sized avatar

Agustinus Kristiadi wiseodd

View GitHub Profile
@wiseodd
wiseodd / Gaussian MLE Anomaly Detection.ipynb
Created October 27, 2015 05:27
Gaussian MLE Anomaly Detection
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wiseodd
wiseodd / Gaussian Anomaly Detection - Bayesian.ipynb
Created October 27, 2015 08:40
Gaussian Anomaly Detection - Bayesian
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
from sklearn.datasets import make_moons
from sklearn.cross_validation import train_test_split
n_feature = 2
n_class = 2
def make_network(n_hidden=100):
@wiseodd
wiseodd / gan.py
Last active September 1, 2020 10:22
Generative Adversarial Nets (GAN) implementation in TensorFlow using MNIST Data.
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import os
def xavier_init(size):
in_dim = size[0]
@wiseodd
wiseodd / pde_numpy.py
Created January 8, 2017 05:48
Implementation of Finite Difference solution of Laplace Equation in Numpy and Theano
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import time
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
plt.ion()
fig = plt.figure()
@wiseodd
wiseodd / natural_grad.py
Created March 13, 2018 19:36
Natural Gradient Descent for Logistic Regression
import numpy as np
from sklearn.utils import shuffle
# Data comes from y = f(x) = [2, 3].x + [5, 7]
X0 = np.random.randn(100, 2) - 1
X1 = np.random.randn(100, 2) + 1
X = np.vstack([X0, X1])
t = np.vstack([np.zeros([100, 1]), np.ones([100, 1])])
@wiseodd
wiseodd / llla_img2img.ipynb
Created November 23, 2022 13:38
Last-Layer Laplace for Image2Image Problems
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import warnings
warnings.filterwarnings('ignore')
import torch
from laplace import Laplace
from helper.dataloaders import get_sinusoid_example
from laplace import Laplace
n_epochs = 1000
torch.manual_seed(711)
@wiseodd
wiseodd / beam_search.py
Created March 31, 2024 17:57
Beam Search
import torch
import tqdm
from transformers import GPT2Tokenizer, GPT2LMHeadModel
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
tokenizer.pad_token = tokenizer.eos_token
model = GPT2LMHeadModel.from_pretrained('gpt2').to(torch.bfloat16)
assert next(model.parameters()).dtype == torch.bfloat16
input_text = 'Earth is'
from laplace import Laplace
from laplace.curvature import CurvlinopsGGN
import torch
from torch import nn
import torch.utils.data as data_utils
from collections import UserDict
import collections.abc as cols_abc
class Model(nn.Module):