如何通过矩阵在CNN中进行正向传播?

时间:2019-03-10 09:14:51

标签: python-3.x deep-learning jupyter-notebook conv-neural-network

我想问一下如何使用矩阵形式在CNN中进行正向传播。 输入已经给出,如何编写输出公式

 def forward(self, input, weights, bias):
        """
        # Arguments
            input: numpy array with shape (batch, in_channel, in_height, in_width)
            weights: numpy array with shape (out_channel, in_channel, kernel_h, kernel_w)
            bias: numpy array with shape (out_channel)

        # Returns
            output: numpy array with shape (batch, out_channel, out_height, out_width)
        """
        kernel_h = self.conv_params['kernel_h']  # height of kernel
        kernel_w = self.conv_params['kernel_w']  # width of kernel
        pad = self.conv_params['pad']
        stride = self.conv_params['stride']
        in_channel = self.conv_params['in_channel']
        out_channel = self.conv_params['out_channel']

        output = None

        #########################################
        How to write the ouput here?
        #########################################

1 个答案:

答案 0 :(得分:0)

学习理论。您可以轻松地实现它。

这是在keras中实现的简短教程。阅读和理解。我想那你可以在原始python中实现 https://towardsdatascience.com/build-your-own-convolution-neural-network-in-5-mins-4217c2cf964f

旅途愉快。