Skip to content

Instantly share code, notes, and snippets.

View wangg12's full-sized avatar

Gu Wang wangg12

View GitHub Profile
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from keras.layers.normalization import BatchNormalization
#AlexNet with batch normalization in Keras
#input image is 224x224
model = Sequential()
model.add(Convolution2D(64, 3, 11, 11, border_mode='full'))
@wangg12
wangg12 / dnn.py
Created October 7, 2015 09:54 — forked from syhw/dnn.py
A simple deep neural network with or w/o dropout in one file.
"""
A deep neural network with or w/o dropout in one file.
License: Do What The Fuck You Want to Public License http://www.wtfpl.net/
"""
import numpy, theano, sys, math
from theano import tensor as T
from theano import shared
from theano.tensor.shared_randomstreams import RandomStreams
@wangg12
wangg12 / batch_norm.py
Created May 11, 2016 09:41 — forked from f0k/batch_norm.py
Batch Normalization for Lasagne
# -*- coding: utf-8 -*-
"""
Preliminary implementation of batch normalization for Lasagne.
Does not include a way to properly compute the normalization factors over the
full training set for testing, but can be used as a drop-in for training and
validation.
Author: Jan Schlüter
"""
@wangg12
wangg12 / InfoGAN-Tutorial.ipynb
Created October 23, 2016 02:22 — forked from awjuliani/InfoGAN-Tutorial.ipynb
An implementation of InfoGAN.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wangg12
wangg12 / setup.md
Created November 29, 2016 10:56 — forked from chris-jamieson/setup.md
Set up Franz for Ubuntu
  • Download Franz for your distribution from MeetFranz.com
  • change into the same directory as the downloaded file, then sudo tar -xf Franz-linux-x64-0.9.10.tgz -C /opt/franz
  • (optional) wget "https://cdn-images-1.medium.com/max/360/1*v86tTomtFZIdqzMNpvwIZw.png" -O franz-icon.png then sudo cp franz-icon.png /opt/franz
  • (optional) sudo touch /usr/share/applications/franz.desktop then sudo vim /usr/share/applications/franz.desktop

paste the following lines into the file, then save the file:

[Desktop Entry]
Name=Franz
Comment=
This file has been truncated, but you can view the full file.
INFO:root:Namespace(aug_level=2, batch_size=256, bn_mom=0.9, data_dir='data/imagenet', data_type='imagenet', depth=101, frequent=50, gpus='0,1,2,3,4,5,6,7', kv_store='device', list_dir='./', lr=0.1, memonger=False, model_load_epoch=0, mom=0.9, num_classes=1000, num_examples=1281167, retrain=False, wd=0.0001, workspace=512)
[00:03:29] src/io/iter_image_recordio.cc:221: ImageRecordIOParser: data/imagenet/train_480_q90.rec, use 4 threads for decoding..
[00:03:32] src/io/iter_image_recordio.cc:221: ImageRecordIOParser: data/imagenet/val_256_q90.rec, use 4 threads for decoding..
INFO:root:Start training with [gpu(0), gpu(1), gpu(2), gpu(3), gpu(4), gpu(5), gpu(6), gpu(7)]
INFO:root:Epoch[0] Batch [50] Speed: 136.63 samples/sec Train-accuracy=0.001328
INFO:root:Epoch[0] Batch [50] Speed: 136.63 samples/sec Train-top_k_accuracy_5=0.006406
INFO:root:Epoch[0] Batch [100] Speed: 132.44 samples/sec Train-accuracy=0.001328
INFO:root:Epoch[0] Batch [100] Speed: 132.44 samples/sec Train-top_k_accuracy_5=0.005625
import torch
from torch.autograd import Variable
import torch.nn as nn
import numpy as np
import torch.optim as optim
import torch.nn.functional as F
import time
from torchvision.models import vgg
# Initialize network
@wangg12
wangg12 / example.py
Created February 21, 2017 15:43 — forked from mrdrozdov/example.py
Logging in Tensorflow
from tf_logger import TFLogger
""" Example of using TFLogger to save train & dev statistics. To visualize
in tensorboard simply do:
tensorboard --logdir /path/to/summaries
This code does depend on Tensorflow, but does not require that your model
is built using Tensorflow. For instance, could build a model in Chainer, then
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.