lungs_var3_d8g_222f.py 文件源码

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

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

    #height = cells.shape[3]  # should be 224 for our data
    width = cells.shape[4]
    crop = (width - grid ) // 2 ## for simplicity we are assuming the same crop (and grid) vertically and horizontally
    #dspacing = gridwidth * gridheight
    #layers = cells.shape[0] // dspacing

    cells = cells[:,:,:,crop:-crop,crop:-crop]     

    shape = cells.shape
    new_shape_1_dim = shape[0]//36
    new_shape = (36, new_shape_1_dim, ) +  tuple([x for x in shape][1:]) 
    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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号