當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。