Created
September 15, 2017 07:14
-
-
Save zhpmatrix/0f78b382ef7d7e552ad71dfd9963de74 to your computer and use it in GitHub Desktop.
So many cool coding tricks from course 《Deep Learning》of Andrew Ng
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
归一化的代码:
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
assert(dw.shape == w.shape)
assert(db.dtype == float)