Skip to content

Instantly share code, notes, and snippets.

View leemengtw's full-sized avatar
🤖
I write random stuffs about AI/ML/DS @ leemeng.tw (in Chinese)

Meng Lee leemengtw

🤖
I write random stuffs about AI/ML/DS @ leemeng.tw (in Chinese)
View GitHub Profile
@leemengtw
leemengtw / create_placeholders_for_cnn.py
Last active November 4, 2017 11:06
圖片size固定
def create_placeholders(n_H0, n_W0, n_C0, n_y):
"""
Creates the placeholders for the tensorflow session.
Arguments:
n_H0 -- scalar, height of an input image
n_W0 -- scalar, width of an input image
n_C0 -- scalar, number of channels of the input
n_y -- scalar, number of classes
def conv_forward(A_prev, W, b, hparameters):
"""
Implements the forward propagation for a convolution function
Arguments:
A_prev -- output activations of the previous layer, numpy array of shape (m, n_H_prev, n_W_prev, n_C_prev)
W -- Weights, numpy array of shape (f, f, n_C_prev, n_C)
b -- Biases, numpy array of shape (1, 1, 1, n_C)
hparameters -- python dictionary containing "stride" and "pad"
@leemengtw
leemengtw / conv_single_step.py
Last active November 3, 2017 14:52
注意b的dimension
def conv_single_step(a_slice_prev, W, b):
"""
Apply one filter defined by parameters W on a single slice (a_slice_prev) of the output activation
of the previous layer.
Arguments:
a_slice_prev -- slice of input data of shape (f, f, n_C_prev)
W -- Weight parameters contained in a window - matrix of shape (f, f, n_C_prev)
b -- Bias parameters contained in a window - matrix of shape (1, 1, 1)
import numpy as np
def zero_pad(X, pad):
"""
Pad with zeros all images of the dataset X. The padding is applied to the height and width of an image,
as illustrated in Figure 1.
Argument:
X -- python numpy array of shape (m, n_H, n_W, n_C) representing a batch of m images
pad -- integer, amount of padding around each image on vertical and horizontal dimensions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leemengtw
leemengtw / copy_files_from_one_folder_to_another
Last active December 21, 2017 01:17
複製資料夾A裡頭所有東西到資料夾B
cp -a /source/. /dest/
References
- https://askubuntu.com/questions/86822/how-can-i-copy-the-contents-of-a-folder-to-another-folder-in-a-different-directo

一開始下載的conda package可能是比較舊的版本, 記得更新 Conda 像是pip 一樣可以管理lib, 不過不限於python lib, 也能裝非python lib, 另外numpy, scikit等lib 是使用pre-compiled 的 MKL 版本, 更快. 而且也可以管理虛擬環境, 就像是pyenv

Package download

update conda

$conda upgrade conda
@leemengtw
leemengtw / undo_git_merge
Last active December 21, 2017 01:17
local branch merge別的branch想要redo(commit_sha 在 sourcetree 對想要回去的commit 按右鍵取得SHA)
References
- https://stackoverflow.com/questions/2389361/undo-a-git-merge-that-hasnt-been-pushed-yet
$git reset --hard commit_sha
@leemengtw
leemengtw / clone_heroku_master
Last active December 21, 2017 01:16
複製heroku master branch下來
References
- https://stackoverflow.com/questions/1376718/is-it-possible-to-retrieve-your-source-code-from-heroku
$heroku login
$heroku git:clone -a YOUR_APP_NAME
$ cd YOUR_APP_NAME
$git add .
$ git commit -am "make it better"
$ git push heroku master
@leemengtw
leemengtw / push_different_branch_to_heroku_master
Last active December 21, 2017 01:16
把master以外的bransh上傳到Heroku master
References
- https://stackoverflow.com/questions/2971550/how-to-push-different-local-git-branches-to-heroku-master
git push heroku heroku-deploy-with-aws-setting:master