|
|
@ -452,21 +452,18 @@ def dist(x, y, p=2):
|
|
|
|
|
|
|
|
|
|
|
|
def dot(x, y, name=None):
|
|
|
|
def dot(x, y, name=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
:alias_main: paddle.dot
|
|
|
|
|
|
|
|
:alias: paddle.dot,paddle.tensor.dot,paddle.tensor.linalg.dot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This operator calculates inner product for vectors.
|
|
|
|
This operator calculates inner product for vectors.
|
|
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
.. note::
|
|
|
|
Only support 1-d Tensor(vector).
|
|
|
|
Only support 1-d Tensor(vector).
|
|
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
Parameters:
|
|
|
|
x(Variable): 1-D ``Tensor`` or ``LoDTensor``. Its datatype should be ``float32``, ``float64``, ``int32``, ``int64``
|
|
|
|
x(Tensor): 1-D ``Tensor``. Its datatype should be ``float32``, ``float64``, ``int32``, ``int64``
|
|
|
|
y(Variable): 1-D ``Tensor`` or ``LoDTensor``. Its datatype soulde be ``float32``, ``float64``, ``int32``, ``int64``
|
|
|
|
y(Tensor): 1-D ``Tensor``. Its datatype soulde be ``float32``, ``float64``, ``int32``, ``int64``
|
|
|
|
name(str, optional): Name of the output. Default is None. It's used to print debug info for developers. Details: :ref:`api_guide_Name`
|
|
|
|
name(str, optional): Name of the output. Default is None. It's used to print debug info for developers. Details: :ref:`api_guide_Name`
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
Variable: the calculated result Tensor/LoDTensor.
|
|
|
|
Variable: the calculated result Tensor.
|
|
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
|
|
|
@ -476,9 +473,11 @@ def dot(x, y, name=None):
|
|
|
|
import paddle.fluid as fluid
|
|
|
|
import paddle.fluid as fluid
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
with fluid.dygraph.guard():
|
|
|
|
paddle.disable_static()
|
|
|
|
x = fluid.dygraph.to_variable(np.random.uniform(0.1, 1, [10]).astype(np.float32))
|
|
|
|
x_data = np.random.uniform(0.1, 1, [10]).astype(np.float32)
|
|
|
|
y = fluid.dygraph.to_variable(np.random.uniform(1, 3, [10]).astype(np.float32))
|
|
|
|
y_data = np.random.uniform(1, 3, [10]).astype(np.float32)
|
|
|
|
|
|
|
|
x = paddle.to_variable(x_data)
|
|
|
|
|
|
|
|
y = paddle.to_variable(y_data)
|
|
|
|
z = paddle.dot(x, y)
|
|
|
|
z = paddle.dot(x, y)
|
|
|
|
print(z.numpy())
|
|
|
|
print(z.numpy())
|
|
|
|
|
|
|
|
|
|
|
@ -651,11 +650,8 @@ def cross(x, y, axis=None, name=None):
|
|
|
|
return out
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cholesky(x, upper=False):
|
|
|
|
def cholesky(x, upper=False, name=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
:alias_main: paddle.cholesky
|
|
|
|
|
|
|
|
:alias: paddle.cholesky,paddle.tensor.cholesky,paddle.tensor.linalg.cholesky
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Computes the Cholesky decomposition of one symmetric positive-definite
|
|
|
|
Computes the Cholesky decomposition of one symmetric positive-definite
|
|
|
|
matrix or batches of symmetric positive-definite matrice.
|
|
|
|
matrix or batches of symmetric positive-definite matrice.
|
|
|
|
|
|
|
|
|
|
|
@ -680,14 +676,13 @@ def cholesky(x, upper=False):
|
|
|
|
.. code-block:: python
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
|
|
import paddle
|
|
|
|
import paddle
|
|
|
|
import paddle.fluid as fluid
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
with fluid.dygraph.guard():
|
|
|
|
paddle.disable_static()
|
|
|
|
a = np.random.rand(3, 3)
|
|
|
|
a = np.random.rand(3, 3)
|
|
|
|
a_t = np.transpose(a, [1, 0])
|
|
|
|
a_t = np.transpose(a, [1, 0])
|
|
|
|
x = np.matmul(a, a_t) + 1e-03
|
|
|
|
x_data = np.matmul(a, a_t) + 1e-03
|
|
|
|
x = fluid.dygraph.to_variable(x)
|
|
|
|
x = paddle.to_variable(x_data)
|
|
|
|
out = paddle.cholesky(x, upper=False)
|
|
|
|
out = paddle.cholesky(x, upper=False)
|
|
|
|
print(out.numpy())
|
|
|
|
print(out.numpy())
|
|
|
|
# [[1.190523 0. 0. ]
|
|
|
|
# [[1.190523 0. 0. ]
|
|
|
@ -695,6 +690,8 @@ def cholesky(x, upper=False):
|
|
|
|
# [1.25450498 0.05600871 0.06400121]]
|
|
|
|
# [1.25450498 0.05600871 0.06400121]]
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
if in_dygraph_mode():
|
|
|
|
|
|
|
|
return core.ops.cholesky(x, "upper", upper)
|
|
|
|
check_variable_and_dtype(x, 'dtype', ['float32', 'float64'], 'cholesky')
|
|
|
|
check_variable_and_dtype(x, 'dtype', ['float32', 'float64'], 'cholesky')
|
|
|
|
check_type(upper, 'upper', bool, 'cholesky')
|
|
|
|
check_type(upper, 'upper', bool, 'cholesky')
|
|
|
|
helper = LayerHelper('cholesky', **locals())
|
|
|
|
helper = LayerHelper('cholesky', **locals())
|
|
|
|