Skip to content

Instantly share code, notes, and snippets.

@zhpmatrix
Created September 15, 2017 07:14
Show Gist options
  • Save zhpmatrix/0f78b382ef7d7e552ad71dfd9963de74 to your computer and use it in GitHub Desktop.
Save zhpmatrix/0f78b382ef7d7e552ad71dfd9963de74 to your computer and use it in GitHub Desktop.
So many cool coding tricks from course 《Deep Learning》of Andrew Ng
# initialize the parameters of logistic regression
def initialize_with_zeros(dim):
"""
This function creates a vector of zeros of shape (dim, 1) for w and initializes b to 0.
Argument:
dim -- size of the w vector we want (or number of parameters in this case)
Returns:
w -- initialized vector of shape (dim, 1)
b -- initialized scalar (corresponds to the bias)
"""
### START CODE HERE ### (≈ 1 line of code)
w = None
b = None
### END CODE HERE ###
assert(w.shape == (dim, 1))
assert(isinstance(b, float) or isinstance(b, int))
return w, b
@zhpmatrix
Copy link
Author

assert(dw.shape == w.shape)
assert(db.dtype == float)

@zhpmatrix
Copy link
Author

归一化的代码:

x -= np.mean(x, axis=0)

x /= np.std(x,axis=0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment