Код: Выделить всё
# GRADED FUNCTION: initialize_with_zeros
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) of type float
"""
# (≈ 2 lines of code)
#w = ...
# b = ...
# YOUR CODE STARTS HERE
w = np.zeros((dim,1))
b = np.zeros(dtype = float)
# YOUR CODE ENDS HERE
return w, b
Код: Выделить всё
dim = 2
w, b = initialize_with_zeros(dim)
assert type(b) == float
print ("w = " + str(w))
print ("b = " + str(b))
initialize_with_zeros_test(initialize_with_zeros)
Подробнее здесь: https://stackoverflow.com/questions/703 ... hape-pos-1
Мобильная версия