python类prod()的实例源码

linear.py 文件源码 项目:static-define-by-run 作者: bkvogel 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]

        type_check.expect(
            x_type.dtype.kind == 'f',
            w_type.dtype.kind == 'f',
            x_type.ndim >= 2,
            w_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )
        if n_in.eval() == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == x_type.dtype,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
function_binary_linear.py 文件源码 项目:binary_net 作者: hillbig 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]

        type_check.expect(
            x_type.dtype == numpy.float32,
            w_type.dtype == numpy.float32,
            x_type.ndim >= 2,
            w_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )
        if n_in.eval() == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == numpy.float32,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
reshape.py 文件源码 项目:chainer-deconv 作者: germanRos 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        type_check.expect(
            in_types.size() == 1,
        )

        x_type, = in_types

        cnt = _count_unknown_dims(self.shape)
        if cnt == 0:
            type_check.expect(
                type_check.prod(x_type.shape) == type_check.prod(self.shape))
        else:
            known_size = 1
            for s in self.shape:
                if s > 0:
                    known_size *= s
            size_var = type_check.Variable(known_size,
                                           'known_size(=%d)' % known_size)
            type_check.expect(
                type_check.prod(x_type.shape) % size_var == 0)
linear.py 文件源码 项目:chainer-deconv 作者: germanRos 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]

        type_check.expect(
            x_type.dtype == numpy.float32,
            w_type.dtype == numpy.float32,
            x_type.ndim >= 2,
            w_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )
        if n_in.eval() == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == numpy.float32,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
function_binary_linear.py 文件源码 项目:XNOR-Net 作者: rarilurelo 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]

        type_check.expect(
            x_type.dtype == numpy.float32,
            w_type.dtype == numpy.float32,
            x_type.ndim >= 2,
            w_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )
        if n_in.eval() == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == numpy.float32,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
function_binary_linear.py 文件源码 项目:GUINNESS 作者: HirokiNakahara 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]

        type_check.expect(
            x_type.dtype == numpy.float32,
            w_type.dtype == numpy.float32,
            x_type.ndim >= 2,
            w_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )
        if n_in.eval() == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == numpy.float32,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
linear.py 文件源码 项目:ddnn 作者: kunglab 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(3 <= n_in, n_in <= 4)
        x_type, w_type, g_type = in_types[:3]

        type_check.expect(
            x_type.dtype.kind == "f",
            w_type.dtype.kind == "f",
            g_type.dtype.kind == "f",
            x_type.ndim >= 2,
            w_type.ndim == 2,
            g_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )

        if n_in.eval() == 4:
            b_type = in_types[3]
            type_check.expect(
                b_type.dtype == x_type.dtype,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
function_binary_linear.py 文件源码 项目:ddnn 作者: kunglab 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]

        type_check.expect(
            x_type.dtype == numpy.float32,
            w_type.dtype == numpy.float32,
            x_type.ndim >= 2,
            w_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )
        if n_in.eval() == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == numpy.float32,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
function_binary_linear.py 文件源码 项目:BinaryNetConvolution 作者: rarilurelo 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]

        type_check.expect(
            x_type.dtype == numpy.float32,
            w_type.dtype == numpy.float32,
            x_type.ndim >= 2,
            w_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )
        if n_in.eval() == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == numpy.float32,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
linear.py 文件源码 项目:unrolled-gan 作者: musyoku 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(3 <= n_in, n_in <= 4)
        x_type, w_type, g_type = in_types[:3]

        type_check.expect(
            x_type.dtype.kind == "f",
            w_type.dtype.kind == "f",
            g_type.dtype.kind == "f",
            x_type.ndim >= 2,
            w_type.ndim == 2,
            g_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )

        if n_in.eval() == 4:
            b_type = in_types[3]
            type_check.expect(
                b_type.dtype == x_type.dtype,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
linear.py 文件源码 项目:LSGAN 作者: musyoku 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(3 <= n_in, n_in <= 4)
        x_type, w_type, g_type = in_types[:3]

        type_check.expect(
            x_type.dtype.kind == "f",
            w_type.dtype.kind == "f",
            g_type.dtype.kind == "f",
            x_type.ndim >= 2,
            w_type.ndim == 2,
            g_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )

        if n_in.eval() == 4:
            b_type = in_types[3]
            type_check.expect(
                b_type.dtype == x_type.dtype,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
model.py 文件源码 项目:reinforcement-learning 作者: musyoku 项目源码 文件源码 阅读 53 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(2 <= n_in, n_in <= 3)
        x_type, w_type = in_types[:2]

        type_check.expect(
            x_type.dtype == np.float32,
            w_type.dtype == np.float32,
            x_type.ndim >= 2,
            w_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )
        if n_in.eval() == 3:
            b_type = in_types[2]
            type_check.expect(
                b_type.dtype == np.float32,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )
linear.py 文件源码 项目:adgm 作者: musyoku 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def check_type_forward(self, in_types):
        n_in = in_types.size()
        type_check.expect(3 <= n_in, n_in <= 4)
        x_type, w_type, g_type = in_types[:3]

        type_check.expect(
            x_type.dtype.kind == "f",
            w_type.dtype.kind == "f",
            g_type.dtype.kind == "f",
            x_type.ndim >= 2,
            w_type.ndim == 2,
            g_type.ndim == 2,
            type_check.prod(x_type.shape[1:]) == w_type.shape[1],
        )

        if n_in.eval() == 4:
            b_type = in_types[3]
            type_check.expect(
                b_type.dtype == x_type.dtype,
                b_type.ndim == 1,
                b_type.shape[0] == w_type.shape[0],
            )


问题


面经


文章

微信
公众号

扫码关注公众号