model_analyzer.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Generative-ConvACs 作者: HUJI-Deep 项目源码 文件源码
def im2col_indices(x, field_height, field_width, padding=1, stride=1, precomputed_indices=None):
    """ An implementation of im2col based on some fancy indexing """
    x_padded = None
    if padding > 0:
        # Zero-pad the input
        p = padding
        x_padded = np.pad(x, ((0, 0), (0, 0), (p, p), (p, p)), mode='constant')
    else:
        x_padded = np.copy(x)

    if precomputed_indices is None:
        k, i, j = get_im2col_indices(x.shape, field_height, field_width, padding, stride)
    else:
        k, i, j = precomputed_indices

    cols = x_padded[k, i, j]
    return cols
######### End of External Code ##########
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号