fit_unet_d8g_222_swrap_07.py 文件源码

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

项目:kaggle_dsb2017 作者: astoc 项目源码 文件源码
def data_from_grid (cells, gridwidth, gridheight, grid=32):

    width = cells.shape[4]
    crop = (width - grid ) // 2 ## for simplicity we are assuming the same crop (and grid) in x & y directions 

    if crop > 0:  # do NOT crop with 0 as we get empty cells ...
        cells = cells[:,:,:,crop:-crop,crop:-crop]     

    shape = cells.shape
    new_shape_1_dim = shape[0]// (gridwidth * gridheight)  # ws // 36 -- Improved on 20170306
    new_shape = (gridwidth * gridheight, new_shape_1_dim, ) +  tuple([x for x in shape][1:])   # was 36,  Improved on 20170306
    cells = np.reshape(cells, new_shape)  
    cells = np.moveaxis(cells, 0, -3)

    shape = cells.shape
    new_shape2 = tuple([x for x in shape[0:3]]) + (gridheight, gridwidth,) + tuple([x for x in shape[4:]])
    cells = np.reshape(cells, new_shape2)
    cells = cells.swapaxes(-2, -3)
    shape = cells.shape
    combine_shape =tuple([x for x in shape[0:3]]) + (shape[-4]*shape[-3], shape[-2]*shape[-1],)
    cells = np.reshape(cells, combine_shape)

    return cells
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号