visualization.py 文件源码

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

项目:caffe-tools 作者: davidstutz 项目源码 文件源码
def visualize_weights(net, layer, zoom = 2):
    """
    Visualize weights in a fully conencted layer.

    :param net: caffe network
    :type net: caffe.Net
    :param layer: layer name
    :type layer: string
    :param zoom: the number of pixels (in width and height) per weight
    :type zoom: int
    :return: image visualizing the kernels in a grid
    :rtype: numpy.ndarray
    """

    assert layer in get_layers(net), "layer %s not found" % layer

    weights = net.params[layer][0].data
    weights = (weights - numpy.min(weights))/(numpy.max(weights) - numpy.min(weights))
    return cv2.resize(weights, (weights.shape[0]*zoom, weights.shape[1]*zoom), weights, 0, 0, cv2.INTER_NEAREST)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号