当前位置: 首页>>代码示例>>Python>>正文


Python multiarray.dot方法代码示例

本文整理汇总了Python中numpy.core.multiarray.dot方法的典型用法代码示例。如果您正苦于以下问题:Python multiarray.dot方法的具体用法?Python multiarray.dot怎么用?Python multiarray.dot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy.core.multiarray的用法示例。


在下文中一共展示了multiarray.dot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: restoredot

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def restoredot():
    """
    Restore `dot`, `vdot`, and `innerproduct` to the default non-BLAS
    implementations.

    Typically, the user will only need to call this when troubleshooting
    and installation problem, reproducing the conditions of a build without
    an accelerated BLAS, or when being very careful about benchmarking
    linear algebra operations.

    .. note:: Deprecated in Numpy 1.10
              The cblas functions have been integrated into the multarray
              module and restoredot now longer does anything. It will be
              removed in Numpy 1.11.0.

    See Also
    --------
    alterdot : `restoredot` undoes the effects of `alterdot`.

    """
    # 2014-08-13, 1.10
    warnings.warn("restoredot no longer does anything.", DeprecationWarning) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:24,代码来源:numeric.py

示例2: test_dot

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_dot(self):
        a = np.array([[1, 0], [0, 1]])
        b = np.array([[0, 1], [1, 0]])
        c = np.array([[9, 1], [1, -9]])

        assert_equal(np.dot(a, b), a.dot(b))
        assert_equal(np.dot(np.dot(a, b), c), a.dot(b).dot(c))

        # test passing in an output array
        c = np.zeros_like(a)
        a.dot(b, c)
        assert_equal(c, np.dot(a, b))

        # test keyword args
        c = np.zeros_like(a)
        a.dot(b=b, out=c)
        assert_equal(c, np.dot(a, b)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:test_multiarray.py

示例3: test_dot_3args

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_dot_3args(self):
        from numpy.core.multiarray import dot

        np.random.seed(22)
        f = np.random.random_sample((1024, 16))
        v = np.random.random_sample((16, 32))

        r = np.empty((1024, 32))
        for i in range(12):
            dot(f, v, r)
        assert_equal(sys.getrefcount(r), 2)
        r2 = dot(f, v, out=None)
        assert_array_equal(r2, r)
        assert_(r is dot(f, v, out=r))

        v = v[:, 0].copy() # v.shape == (16,)
        r = r[:, 0].copy() # r.shape == (1024,)
        r2 = dot(f, v)
        assert_(r is dot(f, v, r))
        assert_array_equal(r2, r) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:test_multiarray.py

示例4: test_dot_override

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_dot_override(self):
        class A(object):
            def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
                return "A"

        class B(object):
            def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
                return NotImplemented

        a = A()
        b = B()
        c = np.array([[1]])

        assert_equal(np.dot(a, b), "A")
        assert_equal(c.dot(a), "A")
        assert_raises(TypeError, np.dot, b, c)
        assert_raises(TypeError, c.dot, b) 
开发者ID:pfchai,项目名称:ImageFusion,代码行数:19,代码来源:test_multiarray.py

示例5: alterdot

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def alterdot():
    """
    Change `dot`, `vdot`, and `inner` to use accelerated BLAS functions.

    Typically, as a user of Numpy, you do not explicitly call this
    function. If Numpy is built with an accelerated BLAS, this function is
    automatically called when Numpy is imported.

    When Numpy is built with an accelerated BLAS like ATLAS, these
    functions are replaced to make use of the faster implementations.  The
    faster implementations only affect float32, float64, complex64, and
    complex128 arrays. Furthermore, the BLAS API only includes
    matrix-matrix, matrix-vector, and vector-vector products. Products of
    arrays with larger dimensionalities use the built in functions and are
    not accelerated.

    .. note:: Deprecated in Numpy 1.10
              The cblas functions have been integrated into the multarray
              module and alterdot now longer does anything. It will be
              removed in Numpy 1.11.0.

    See Also
    --------
    restoredot : `restoredot` undoes the effects of `alterdot`.

    """
    # 2014-08-13, 1.10
    warnings.warn("alterdot no longer does anything.", DeprecationWarning) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:30,代码来源:numeric.py

示例6: test_dot_2args

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_dot_2args(self):
        from numpy.core.multiarray import dot

        a = np.array([[1, 2], [3, 4]], dtype=float)
        b = np.array([[1, 0], [1, 1]], dtype=float)
        c = np.array([[3, 2], [7, 4]], dtype=float)

        d = dot(a, b)
        assert_allclose(c, d) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:test_multiarray.py

示例7: test_dot_3args_errors

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_dot_3args_errors(self):
        from numpy.core.multiarray import dot

        np.random.seed(22)
        f = np.random.random_sample((1024, 16))
        v = np.random.random_sample((16, 32))

        r = np.empty((1024, 31))
        assert_raises(ValueError, dot, f, v, r)

        r = np.empty((1024,))
        assert_raises(ValueError, dot, f, v, r)

        r = np.empty((32,))
        assert_raises(ValueError, dot, f, v, r)

        r = np.empty((32, 1024))
        assert_raises(ValueError, dot, f, v, r)
        assert_raises(ValueError, dot, f, v, r.T)

        r = np.empty((1024, 64))
        assert_raises(ValueError, dot, f, v, r[:, ::2])
        assert_raises(ValueError, dot, f, v, r[:, :32])

        r = np.empty((1024, 32), dtype=np.float32)
        assert_raises(ValueError, dot, f, v, r)

        r = np.empty((1024, 32), dtype=int)
        assert_raises(ValueError, dot, f, v, r) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:test_multiarray.py

示例8: test_matmat

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_matmat(self):
        A = self.A
        c1 = dot(A.transpose(), A)
        c2 = dot_(A.transpose(), A)
        assert_almost_equal(c1, c2, decimal=self.N) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_numeric.py

示例9: test_matvec2

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_matvec2(self):
        A, b2 = self.A, self.b2
        c1 = dot(A, b2)
        c2 = dot_(A, b2)
        assert_almost_equal(c1, c2, decimal=self.N) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_numeric.py

示例10: test_vecmat

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_vecmat(self):
        A, b4 = self.A, self.b4
        c1 = dot(b4, A)
        c2 = dot_(b4, A)
        assert_almost_equal(c1, c2, decimal=self.N) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_numeric.py

示例11: test_vecmat2

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_vecmat2(self):
        b3, A = self.b3, self.A
        c1 = dot(b3, A.transpose())
        c2 = dot_(b3, A.transpose())
        assert_almost_equal(c1, c2, decimal=self.N) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_numeric.py

示例12: test_vecmat3

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_vecmat3(self):
        A, b4 = self.A, self.b4
        c1 = dot(A.transpose(), b4)
        c2 = dot_(A.transpose(), b4)
        assert_almost_equal(c1, c2, decimal=self.N) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_numeric.py

示例13: test_vecvecouter

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_vecvecouter(self):
        b1, b3 = self.b1, self.b3
        c1 = dot(b1, b3)
        c2 = dot_(b1, b3)
        assert_almost_equal(c1, c2, decimal=self.N) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_numeric.py

示例14: test_columnvect1

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_columnvect1(self):
        b1 = ones((3, 1))
        b2 = [5.3]
        c1 = dot(b1, b2)
        c2 = dot_(b1, b2)
        assert_almost_equal(c1, c2, decimal=self.N) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:test_numeric.py

示例15: test_columnvect2

# 需要导入模块: from numpy.core import multiarray [as 别名]
# 或者: from numpy.core.multiarray import dot [as 别名]
def test_columnvect2(self):
        b1 = ones((3, 1)).transpose()
        b2 = [6.2]
        c1 = dot(b2, b1)
        c2 = dot_(b2, b1)
        assert_almost_equal(c1, c2, decimal=self.N) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:test_numeric.py


注:本文中的numpy.core.multiarray.dot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。