Skip to content

Instantly share code, notes, and snippets.

View lanpa's full-sized avatar

Tzu-Wei Huang lanpa

View GitHub Profile
@lanpa
lanpa / gist:4427645
Last active December 10, 2015 11:28
%2013/1/1
%Tzu-Wei Huang
%demo of 'derivative of Gaussian', Difference of Gaussians and
%'Laplacian of Gaussian' in matlab.
close all;
[x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
%gaussian with sigma = 1
z = (1/sqrt(2*pi))./exp((x.^2+y.^2)/2);
@lanpa
lanpa / shop.py
Last active August 29, 2015 14:19
prices = {
"banana": 10,
"apple": 20,
"orange": 15,
"mango": 30
}
shopping_list1 = ["banana", "orange", "apple", "apple", "apple"]
shopping_list2 = ["banana", "orange", "apple", "banana", "apple"]
def sumThemAll(shoplist):
f = open('drinkquiz.txt', 'w')
char_remove = ['。\n。\n', '.\n.\n', '…\n…\n', '.\n.\n', '°\n°\n', '·\n·\n', '•\n•\n', '+\n+\n']
for i in range(2500):
for feed in feeds['data']:
if 'message' in feed:
msg = feed['message']
#print (msg)
for rm in char_remove:
msg = msg.replace(rm,'')
#print(msg)
#!/usr/bin/env bash
set -e
######################################################################
# This script installs required dependencies for Torch7
######################################################################
{
install_openblas() {
# Get and build OpenBlas (Torch is much better with a decent Blas)
@lanpa
lanpa / alexnet.py
Created January 5, 2018 16:44
modified Alexnet
class AlexNet(nn.Module):
def __init__(self, num_classes=1000):
super(AlexNet, self).__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2),
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3, stride=2),
nn.Conv2d(64, 192, kernel_size=5, padding=2),
nn.ReLU(inplace=True),
graph(%0 : Float(1, 3, 224, 224)
%1 : Float(64, 3, 11, 11)
%2 : Float(64)
%3 : Float(192, 64, 5, 5)
%4 : Float(192)
%5 : Float(384, 192, 3, 3)
%6 : Float(384)
%7 : Float(256, 384, 3, 3)
%8 : Float(256)
%9 : Float(256, 256, 3, 3)
graph(%0 : Float(1, 3, 224, 224)
%1 : Float(64, 3, 11, 11)
%2 : Float(64)
%3 : Float(192, 64, 5, 5)
%4 : Float(192)
%5 : Float(384, 192, 3, 3)
%6 : Float(384)
%7 : Float(256, 384, 3, 3)
%8 : Float(256)
%9 : Float(256, 256, 3, 3)
with open ('data.csv') as f:
lines = f.readlines()
valid = []
for line in lines:
a, b = line.strip('\n').split(',')
if a=='1' or a=='2' or a=='3':
print(a, b)
valid.append((int(a), int(b)))
from __future__ import print_function
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.autograd import Variable
from tensorboardX import SummaryWriter
# Training settings
@lanpa
lanpa / gist:debcb8b8d5e674f176817b929f1747ea
Last active February 15, 2018 03:45
pytorch 0.4.0a0+fe810ed trace
class Net1(nn.Module):
def __init__(self):
super(Net1, self).__init__()
self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
self.conv2_drop = nn.Dropout2d()
self.fc1 = nn.Linear(320, 50)
self.fc2 = nn.Linear(50, 10)
self.bn = nn.BatchNorm2d(20)