Skip to content

Instantly share code, notes, and snippets.

View dboyliao's full-sized avatar

dboyliao dboyliao

View GitHub Profile
@dboyliao
dboyliao / svm.py
Created July 14, 2014 12:32 — forked from mblondel/svm.py
# Mathieu Blondel, September 2010
# License: BSD 3 clause
import numpy as np
from numpy import linalg
import cvxopt
import cvxopt.solvers
def linear_kernel(x1, x2):
return np.dot(x1, x2)

[TOC]

Lab Guide for Coding Beginners

亮亮(@ccwang002)| Mar, 2015 | CC 3.0 BY license

如果內容有誤,你可以用任何管道發訊息轟炸我,或用底下的 gist comment 留言。

學習方式

每個檔案都會是一個主題,主題底下會列出一些資源。資源的最後會有一個學習目標,方便讓你評估自己學到什麼程度。學習目標會給一個明確的任務,我盡量讓它能跟(宅宅的)日常生活結合。通常只要完成前一、二個目標就行了,這也不是功課所以不一定要給我看。如果你不介意給我看,我會分享我主觀的建議,但大部份的任務是沒有絕對的正確答案。只要能解決問題都是好方法。

@dboyliao
dboyliao / Scan.py
Last active August 29, 2015 14:22 — forked from enjoylife/Scan.py
# -*- coding: utf-8 -*-
"""
SCAN: A Structural Clustering Algorithm for Networks
As described in http://ualr.edu/nxyuruk/publications/kdd07.pdf
"""
from collections import deque
import numpy as np
from scipy.sparse import csr_matrix
class A:
def __init__(self):
self.a = 1
@property
def a(self):
return 2
a = A()
#!/path/to/the/python/interpreter/in/virtualenv
# -*- coding: utf-8 -*-
import subprocess
import sys
def main():
try:
subprocess.call("echo 'Hello!'", shell = True)
sys.exit(0)
#include <stdio.h>
typedef int (*myFun)(int x, int y);
void helper(myFun afun){
afun(1, 1);
}
int fun(int x, int y){
printf("%d %d", x, y);
l = [[1,2,3,4,5], [5,6,7,50], [10,20,30]]
i_max, (j_max, v_max) = max(enumerate([max(enumerate(ll), key = lambda t: t[1]) for ll in l]), key = lambda t: t[1][1])
# >>> i_max = 1, j_max = 3, v_max = 50
class People:
def __init__(self, name):
self.name = name
def __str__(self):
return "Hello, I'm {}".format(self.name)
def __repr__(self):
return "<type People>: name = '{}'".format(self.name)
import Accelerate
var realp = [Float]([1, 2, 3])
var imagp = [Float]([4, 5, 6])
var z = DSPSplitComplex(realp: &realp, imagp: &imagp)
// vDSP_ctoz(x, 2, &z, 1, vDSP_Length(6))
for i in 0..<12 {
print(z.realp[i])
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import numpy as np
import random
"""
Simple Back-Propagation Neural Network.
Basic Usage: