0
我想初始化以下神經網絡模型初始化1層的神經網絡參數
高清initialize_parameters(n_x,N_H,n_y):
W1 = np.random.randn(4,2) *0.01
b1 = np.zeros((4,1))
W2 = np.random.randn(1,4) * 0.01
b2 = np.zeros((1,1))
assert (W1.shape == (n_h, n_x))
assert (b1.shape == (n_h, 1))
assert (W2.shape == (n_y, n_h))
assert (b2.shape == (n_y, 1))
parameters = {"W1": W1,
"b1": b1,
"W2": W2,
"b2": b2}
return parameters
我輸出出來的:
W1 = [[-0.00416758 -0.00056267]
[-0.02136196 0.01640271]
[-0.01793436 -0.00841747]
[ 0.00502881 -0.01245288]]
b1 = [[ 0.]
[ 0.]
[ 0.]
[ 0.]]
W2 = [[-0.01057952 -0.00909008 0.00551454 0.02292208]]
b2 = [[ 0.]]
鑑於正確答案應該是:
W1 [[-0.00416758 -0.00056267] [-0.02136196 0.01640271] [-0.01793436 -0.00841747] [ 0.00502881 -0.01245288]]
b1 [[ 0.] [ 0.] [ 0.] [ 0.]]
W2 [[-0.01057952 -0.00909008 0.00551454 0.02292208]]
b2 [[ 0.]]
W1和b1顯然是錯的,但我不能讓它以任何其他方式工作。新手在這裏。提前致謝!
這些值看起來是正確的。您是否正在查看輸出中的格式差異,即您的預期結果和實際結果之間的差異? – saopayne
那麼我在做Andrew NG新的深度學習課程,當我提交這個答案時,它不會被評分。我認爲W1和B1尺寸是錯的? – kyttcar