Skip to content

Instantly share code, notes, and snippets.

View lizhangzhan's full-sized avatar

lizhang lizhangzhan

View GitHub Profile
@lizhangzhan
lizhangzhan / weibull.py
Created September 3, 2020 07:33 — forked from plasmaman/weibull.py
Python code for estimating the shape and scale parameters for a two-parameter Weibull distribution. It uses scipy.optimize.fmin to minimize the Likelihood function.
from scipy.stats import exponweib
from scipy.optimize import fmin
import numpy as np
# x is your data array
# returns [shape, scale]
def fitweibull(x):
def optfun(theta):
return -np.sum(np.log(exponweib.pdf(x, 1, theta[0], scale = theta[1], loc = 0)))
@lizhangzhan
lizhangzhan / brnn.py
Last active October 13, 2017 16:43 — forked from allenanie/brnn.py
Bayesian Recurrent Neural Network Implementation
"""
An implementation of the `Local reparameterization trick`
from Kingma & Wellings and
Bayesian RNN
from Fortunato, Blundell & Vinyals
"""
import os
import time
import copy
from os.path import join as pjoin
@lizhangzhan
lizhangzhan / cifar10_wide_resnet.py
Created July 20, 2017 14:50 — forked from kashif/cifar10_wide_resnet.py
Keras Wide Residual Networks CIFAR-10
from __future__ import print_function
from keras.datasets import cifar10
from keras.layers import merge, Input
from keras.layers.convolutional import Convolution2D, ZeroPadding2D, AveragePooling2D
from keras.layers.core import Dense, Activation, Flatten, Dropout
from keras.layers.normalization import BatchNormalization
from keras.models import Model
from keras.preprocessing.image import ImageDataGenerator
from keras.utils import np_utils
@lizhangzhan
lizhangzhan / DCGAN.ipynb
Created October 3, 2016 06:26 — forked from awjuliani/DCGAN.ipynb
An implementation of DCGAN in Tensorflow and Python.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lizhangzhan
lizhangzhan / conv_deconv_vae.py
Created August 23, 2016 07:49 — forked from kastnerkyle/conv_deconv_vae.py
Convolutional Variational Autoencoder, modified from Alec Radford at (https://gist.github.com/Newmu/a56d5446416f5ad2bbac)
# Alec Radford, Indico, Kyle Kastner
# License: MIT
"""
Convolutional VAE in a single file.
Bringing in code from IndicoDataSolutions and Alec Radford (NewMu)
Additionally converted to use default conv2d interface instead of explicit cuDNN
"""
import theano
import theano.tensor as T
from theano.compat.python2x import OrderedDict
@lizhangzhan
lizhangzhan / vae_mlp.py
Created August 22, 2016 12:03 — forked from tabacof/vae_mlp.py
Variational Auto-Encoder (MLP encoder/decoder)
# -*- coding: utf-8 -*-
"""
Reproducing the results of Auto-Encoding Variational Bayes by Kingma and Welling
With a little help from the code from van Amersfoort and Otto Fabius (https://github.com/y0ast)
@author: Pedro Tabacof (tabacof at gmail dot com)
"""
import random
import numpy as np
"""
Joost van Amersfoort - <joost.van.amersfoort@gmail.com>
Otto Fabius - <ottofabius@gmail.com
License: MIT
"""
import numpy as np
import theano as th
import theano.tensor as T
@lizhangzhan
lizhangzhan / min-char-rnn.py
Created August 12, 2016 15:28 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@lizhangzhan
lizhangzhan / bayesian_neural_network.ipynb
Created March 2, 2016 03:01 — forked from twiecki/bayesian_neural_network.ipynb
Bayesian Neural Network in PyMC3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
""" Poisson-loss Factorization Machines with Numba
Follows the vanilla FM model from:
Steffen Rendle (2012): Factorization Machines with libFM.
In: ACM Trans. Intell. Syst. Technol., 3(3), May.
http://doi.acm.org/10.1145/2168752.2168771
See also: https://github.com/coreylynch/pyFM
"""