柠檬少年|卷积神经网络各层反向传播公式推导
- 前向传播
隐藏层:第二层
第三层:
输出层:
2.反向传播
反向传播算法
参考
def conv_forward(X, W, b, stride=1, padding=1):cache = W, b, stride, paddingn_filters, d_filter, h_filter, w_filter = W.shapen_x, d_x, h_x, w_x = X.shapeh_out = (h_x - h_filter + 2 * padding) / stride + 1w_out = (w_x - w_filter + 2 * padding) / stride + 1if not h_out.is_integer() or not w_out.is_integer():raise Exception('Invalid output dimension!')h_out, w_out = int(h_out), int(w_out)X_col = im2col_indices(X, h_filter, w_filter, padding=padding, stride=stride)W_col = W.reshape(n_filters, -1)out = W_col @ X_col + bout = out.reshape(n_filters, h_out, w_out, n_x)out = out.transpose(3, 0, 1, 2)cache = (X, W, b, stride, padding, X_col)return out, cachedef conv_backward(dout, cache):X, W, b, stride, padding, X_col = cachen_filter, d_filter, h_filter, w_filter = W.shapedb = np.sum(dout, axis=(0, 2, 3))db = db.reshape(n_filter, -1)dout_reshaped = dout.transpose(1, 2, 3, 0).reshape(n_filter, -1)dW = dout_reshaped @ X_col.TdW = dW.reshape(W.shape)W_reshape = W.reshape(n_filter, -1)dX_col = W_reshape.T @ dout_reshapeddX = col2im_indices(dX_col, X.shape, h_filter, w_filter, padding=padding, stride=stride)return dX, dW, db
- 金戈鐵馬|特朗普力挺铁杆支持者,枪杀两人的少年没错?抗议活动不断发酵
- 少年|央视要搞选秀,热搜沸了!网友提名他当导师,点赞数第一
- 暖夏少年|2020电脑硬盘销量排行榜:七彩虹加入战局,硬是打倒了金士顿
- 少年一梦|2020畅销手机排行,iPhone无人超越,安卓旗舰全线溃败
- 少年帮|进入倒计时,华为突然宣布,供应链将迎来“洗牌”?
- 艾希大人|竹内结子拍摄杂志封面 柠檬黄上衣青春活力
- 上线|原创央视也搞成团选秀!《上线吧!华彩少年》有哪些优势?粉丝放心了
- 海报|央视首档少年成团选秀节目《上线吧!华彩少年》开始全球招募
- 少年帮|正式确认?中科院宣布决定,纯国产“龙芯”即将来临
- 光一样的少年|面对后起之秀,苏泊尔不玩价格战,以一抵八多功能破壁机倍受追捧