Skip to content

Instantly share code, notes, and snippets.

@darren1231
darren1231 / test.md
Last active September 26, 2018 07:44

MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications

1.Abstract

類神經網路在近幾年已取得巨大的突破,從最開始的Perceptron一直演化到AlexNet、VGG,精確度一直不斷的往上提升,但伴隨著的是模型複雜化,過度複雜的模型使得運算量極大以至於不能在低階產品(如手機上)運行,MobileNet的發明就是為了解決這想法而產生的,文中和許多當前有名的框架互相比較(Inception V3、VGG),速度真的提升許多,雖然精確度有稍許下降,但也都控制在可以接受的範圍內。

2.Main idea

文中最核心的思想就是把傳統的卷積過程簡化成計算量更少的過程,算式並沒有完全等效,但有趨近於等效的功用,主要是把過程分成Depthwise convolution 和 pointwise convolution,文中用公式來舉例說明

# ydata = b + w * xdata
b = -120 # initial b
w = -4 # initial w
lr = 1 # learning rate
iteration = 100000
b_lr = 0.0
w_lr = 0.0
# Store initial values for plotting.
# ydata = b + w * xdata
b = -120 # initial b
w = -4 # initial w
lr = 0.0000001 # learning rate
iteration = 100000
# Store initial values for plotting.
b_history = [b]
w_history = [w]
from matplotlib import pyplot as plt
import numpy as np
x_data = [ 338., 333., 328. , 207. , 226. , 25. , 179. , 60. , 208., 606.]
y_data = [ 640. , 633. , 619. , 393. , 428. , 27. , 193. , 66. , 226. , 1591.]
x = np.arange(-200,-100,1) #bias
y = np.arange(-5,5,0.1) #weight
Z = np.zeros((len(x), len(y)))
X, Y = np.meshgrid(x, y)
for i in range(len(x)):
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 10 16:41:39 2018
@author: darren
"""
import pandas as pd
import requests
import cv2
import numpy as np
def draw_flow(img, flow, step=16):
h, w = img.shape[:2]
y, x = np.mgrid[step/2:h:step, step/2:w:step].reshape(2,-1).astype(int)
fx, fy = flow[y,x].T
lines = np.vstack([x, y, x+fx, y+fy]).T.reshape(-1, 2, 2)
lines = np.int32(lines + 0.5)
import cv2
# Install instruction on Anaconda:
# conda install -c https://conda.anaconda.org/menpo opencv3
# OpenCV version: 3.1.0
# python version: 3.5.1
# 讀入圖片 (處理用)
@darren1231
darren1231 / greedy_two
Last active March 15, 2017 18:26
greedy_two
Sub fast()
original_col = 26
original_row = 106
Do Until original_col = 1
cut_number = copy_cut(original_row, original_col)
original_col = original_col - cut_number
If original_col = 1 Then
Exit Do
End If
@darren1231
darren1231 / Excel VBA_group_pick_done.txt
Last active February 26, 2017 03:26
Excel VBA greedy algorithm
Public Function main()
For all_row = 2 To 6
been_chose_group = group_pick(all_row)
For n_row = 2 To 6
Cells(6 + n_row + 2, all_row) = been_chose_group(n_row, 0)
Next n_row
@darren1231
darren1231 / Markdown.css
Created February 11, 2017 02:34
Setup for MarkdownPad
/* Markdown.css */
/* Authors: Kevin Burke: http://kev.inburke.com/, modified by Evan Wondrasek */
/* https://bitbucket.org/kevinburke/markdowncss */
body{
margin: 0 auto;
font-family: Georgia, Palatino, serif;
color: #444444;
line-height: 1;