caffe_functions.py 文件源码

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

项目:RealtimeFacialEmotionRecognition 作者: sushant3095 项目源码 文件源码
def vis_square(data, padsize=1, padval=0):
    data -= data.min()
    data /= data.max()

    # Force the number of filters to be square
    n = int(np.ceil(np.sqrt(data.shape[0])))
    padding = ((0, n ** 2 - data.shape[0]), (0, padsize), (0, padsize)) + ((0, 0),) * (data.ndim - 3)
    #UNCOMMENT_THIS data = np.pad(data, padding, mode='reflect', constant_values=(padval, padval))
    data = np.pad(data, padding, mode='constant', constant_values=(padval, padval))

    # Tile the filters into an image
    data = data.reshape((n, n) + data.shape[1:]).transpose((0, 2, 1, 3) + tuple(range(4, data.ndim + 1)))
    data = data.reshape((n * data.shape[1], n * data.shape[3]) + data.shape[4:])
    #IF you want to use Show Image for static images, comment out thr if and return statements 
    if data.ndim == 3:
        data = data[:, :, ::-1]
    return data

    #showimage(data)

# Plot the last image and conv1 layer's weights and responses
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号