python CNN一个过滤器套用在一图片对应区域的输出值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python CNN一个过滤器套用在一图片对应区域的输出值相关的知识,希望对你有一定的参考价值。

def conv_single_step(a_slice_prev, W, b):
    """
    Apply one filter defined by parameters W on a single slice (a_slice_prev) of the output activation 
    of the previous layer.
    
    Arguments:
    a_slice_prev -- slice of input data of shape (f, f, n_C_prev)
    W -- Weight parameters contained in a window - matrix of shape (f, f, n_C_prev)
    b -- Bias parameters contained in a window - matrix of shape (1, 1, 1)
    
    Returns:
    Z -- a scalar value, result of convolving the sliding window (W, b) on a slice x of the input data
    """
    # Element-wise product between a_slice and W. Add bias.
    assert(a_slice_prev.shape == W.shape)
    s = W * a_slice_prev + b
    # Sum over all entries of the volume s
    Z = np.sum(s)
    return Z
    
np.random.seed(1)
a_slice_prev = np.random.randn(4, 4, 3) # height * width * channel
W = np.random.randn(4, 4, 3)
b = np.random.randn(1, 1, 1)

Z = conv_single_step(a_slice_prev, W, b)
print("Z =", Z)
assert '{:.2f}'.format(Z) == '-23.16'

以上是关于python CNN一个过滤器套用在一图片对应区域的输出值的主要内容,如果未能解决你的问题,请参考以下文章

R-CNN, Fast R-CNN, Faster R-CNN, YOLO:目标检测算法总结

Faster R-CNN 学习

CNN基础知识

CNN可视化可行性

python 建立CNN用的占位符,任意图片数

excel为单元格区域套用表格样式以及取消表格样式