Skip to content

Instantly share code, notes, and snippets.

View chaonan99's full-sized avatar
🎯
Focusing

Haonan Chen chaonan99

🎯
Focusing
View GitHub Profile
@chaonan99
chaonan99 / simplex.m
Created April 6, 2016 03:03
Solve LP problem using Simplex Method and Bland's Law.
%% Simplex Method
% /DAA/simplex.m
% Solve LP problem using Simplex Method and Bland's Law.
% chaonan99(R)
% 2016/03/20
% [Note] The input should already have a initial basic feasible solution.
% [Thanks to] http://wenku.baidu.com/link?url=bUal8_VtNYHdIXF97JKo_r6vzYt3lGlSFO2W2Wz6wInLnw-3STZpbyxSoaOIu2XKE3z5O4D5xjErH5_tqXY-j3-DubAapkfCuyraVMxMNNO
%% code
@chaonan99
chaonan99 / twostage.m
Last active April 6, 2016 03:38
Solve LP problem using Two-Stage Method and Bland's Law.
%% Two-Stage Method
% /DAA/twostage.m
% [Function] Solve LP problem using Two-Stage Method and Bland's Law.
% [Author] chaonan99(R)
% [Last modify] 2016/03/28
% [Contect me] [email protected]
% [Note]
% 1. There are no examination on input size, which the user should ensure
% its correctness.
@chaonan99
chaonan99 / screen_capture.m
Created April 6, 2016 03:42
A simple demo of screen capture using Matlab and java AWT
robo = java.awt.Robot;
t = java.awt.Toolkit.getDefaultToolkit();
rectangle = java.awt.Rectangle(t.getScreenSize());
image = robo.createScreenCapture(rectangle);
filehandle = java.io.File('capture.png');
javax.imageio.ImageIO.write(image,'png',filehandle);
im = imread('capture.png');
imshow(im);
@chaonan99
chaonan99 / dual_simplex.m
Created April 6, 2016 03:45
Solve LP problem using Dual Simplex Method and Bland's Law.
%% Dual Simplex Method
% /DAA/dual_simplex.m
% [Description] Solve LP problem using Dual Simplex Method and Bland's Law.
% [Author] chaonan99(R)
% [Last Modify] 2016/04/03
% [Contact Me] [email protected]
% [Note] The input should already have an initial basic solution for the
% original problem and a feasible solution for its dual problem.
@chaonan99
chaonan99 / 0_reuse_code.js
Last active April 6, 2016 04:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@chaonan99
chaonan99 / OR_HW1.m
Last active May 9, 2016 03:43
运筹学的一次作业,用精确直线搜索的梯度法求解非线性规划问题。
function []=OR_HW1()
x=[0,0];
dfx_val = dfx(x);
normdfx = norm(dfx_val);
k = 0;
f_val = zeros(1000,1);
while normdfx>1e-6
t = newton(x,-dfx_val);
x = x-t*dfx_val;
dfx_val = dfx(x);
function []=bs()
x=[0,0];
dfx_val = dfx(x);
normdfx = norm(dfx_val);
k = 0;
f_val = zeros(1000,1);
dfx_val_pre = [1,1];
p_pre = [0,0];
while normdfx>1e-10
if mod(k,2) == 0
@chaonan99
chaonan99 / videosample.py
Last active September 6, 2016 02:12
A script to extract exact number of frames from a sequence video, using *ffmpeg*.
#!/usr/bin/env python
# [Description] A script to extract exact number of frames from a sequence video
# [Author] chaonan99
# [Date] 2016/07/17/
# [Last Modified] 2016/09/01
# [Email] [email protected]
import subprocess as sp
import re
import optparse
@chaonan99
chaonan99 / plotloss.py
Last active July 29, 2016 18:38
plot loss curve from caffe log file.
import re
import matplotlib
import pylab as plt
import numpy as np
s = open('default.log','r').read()
pattern = re.compile(r'iter (\d+): (\d+.\d+)')
grou = np.asarray(pattern.findall(s)).astype(np.float32)
plt.plot(grou[:,0],grou[:,1])
plt.title('title')
@chaonan99
chaonan99 / LSTMAttention.lua
Last active November 18, 2017 16:58
That's a torch implementation of LSTM module with attention mechanism base on Karpathy's implementation in NeuralTalk2
require 'nn'
require 'nngraph'
local LSTM = {}
function LSTM.lstm(input_size, output_size, rnn_size, n, frame_per_video, seq_per_video, dropout)
dropout = dropout or 0
-- TODO: No idea how to choose attention size...
att_size = att_size or 512
-- there will be 2*n+1 inputs