當前位置: 首頁>>代碼示例>>Python>>正文


Python util.im2col方法代碼示例

本文整理匯總了Python中common.util.im2col方法的典型用法代碼示例。如果您正苦於以下問題:Python util.im2col方法的具體用法?Python util.im2col怎麽用?Python util.im2col使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common.util的用法示例。


在下文中一共展示了util.im2col方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: forward

# 需要導入模塊: from common import util [as 別名]
# 或者: from common.util import im2col [as 別名]
def forward(self, x):
        FN, C, FH, FW = self.W.shape
        N, C, H, W = x.shape
        out_h = 1 + int((H + 2 * self.pad - FH) / self.stride)
        out_w = 1 + int((W + 2 * self.pad - FW) / self.stride)

        col = im2col(x, FH, FW, self.stride, self.pad)
        col_W = self.W.reshape(FN, -1).T

        out = np.dot(col, col_W) + self.b
        out = out.reshape(N, out_h, out_w, -1).transpose(0, 3, 1, 2)

        self.x = x
        self.col = col
        self.col_W = col_W

        return out 
開發者ID:kenji0x02,項目名稱:srcnn-from-scratch,代碼行數:19,代碼來源:layers.py

示例2: forward

# 需要導入模塊: from common import util [as 別名]
# 或者: from common.util import im2col [as 別名]
def forward(self, x):
        FN, C, FH, FW = self.W.shape
        N, C, H, W = x.shape
        out_h = 1 + int((H + 2*self.pad - FH) / self.stride)
        out_w = 1 + int((W + 2*self.pad - FW) / self.stride)

        col = im2col(x, FH, FW, self.stride, self.pad)
        col_W = self.W.reshape(FN, -1).T

        out = np.dot(col, col_W) + self.b
        out = out.reshape(N, out_h, out_w, -1).transpose(0, 3, 1, 2)

        self.x = x
        self.col = col
        self.col_W = col_W

        return out 
開發者ID:HyeongTak,項目名稱:Learning-Deep-Learning,代碼行數:19,代碼來源:layers.py

示例3: forward

# 需要導入模塊: from common import util [as 別名]
# 或者: from common.util import im2col [as 別名]
def forward(self, x):
        FN, C, FH, FW = self.W.shape # 30, 1, 5, 5
        N, C, H, W = x.shape
        out_h = 1 + int((H + 2*self.pad - FH) / self.stride)
        out_w = 1 + int((W + 2*self.pad - FW) / self.stride)

        """
        im2col method 4d to 2d
        input: (batch size, input_filternum, input height, input width)
        output: (output height * output width * batch size, filter_h * filter_w * input_filternum)

        input_filternum == channel num
        """
        col = im2col(x, FH, FW, self.stride, self.pad)
        col_W = self.W.reshape(FN, -1).T
        out = np.dot(col, col_W) + self.b
        # reshape to tensor
        out = out.reshape(N, out_h, out_w, -1).transpose(0, 3, 1, 2)

        self.x = x
        self.col = col
        self.col_W = col_W

        return out 
開發者ID:YeongHyeon,項目名稱:R-CNN_LIGHT,代碼行數:26,代碼來源:layers.py


注:本文中的common.util.im2col方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。