Exemple #1
0
def randint(low, high, size, dtype="int64", requires_grad=False):
    return Tensor(
        fluid.layers.randint(low,
                             high=high,
                             shape=size,
                             out=None,
                             dtype=dtype,
                             device=None,
                             stop_gradient=not requires_grad))
Exemple #2
0
def rand(*shape):
    if isinstance(shape, int):
        shape = [shape]
    if isinstance(shape[0], Iterable):
        shape = shape[0]
    return Tensor(paddle.rand(shape))
Exemple #3
0
def matmul(x, y):
    return Tensor(fluid.layers.matmul(x, y))
Exemple #4
0
def dot(x, y):
    return Tensor(fluid.layers.dot(x, y))
Exemple #5
0
def sigmoid(x):
    return Tensor(fluid.layers.sigmoid(x))
Exemple #6
0
def bmm(x, y):
    return Tensor(fluid.layers.bmm(x, y))
Exemple #7
0
def arange(*args, **kwargs):
    return Tensor(np.arange(*args, **kwargs).astype("int32"))
Exemple #8
0
def flip(self, dim):
    return Tensor(paddle.flip(self, dims=[dim]))
Exemple #9
0
def trace(x, offset=0, dim1=0, dim2=1, out=None):
    return Tensor(paddle.trace(x, offset, dim1, dim2, out))
Exemple #10
0
def bmm(x, y, transpose=False):
    if transpose:
        y = y.transpose(len(y.shape) - 1, len(y.shape) - 2)
    return Tensor(paddle.bmm(x, y))
Exemple #11
0
def eye(n, m=None):
    if m is None:
        m = n
    return Tensor(paddle.eye(n, m))
Exemple #12
0
def from_numpy(x):
    return Tensor(x)
Exemple #13
0
def LongTensor(x):
    if isinstance(x, int):
        return Tensor(paddle.to_tensor([x]))
    if isinstance(x, list):
        x = paddle.to_tensor(x, dtype="int64")
    return convertTensor(x.astype("int64"))
Exemple #14
0
def floor(x):
    return Tensor(paddle.floor(x))
Exemple #15
0
def flip(self, dim):
    return Tensor(fluid.layers.flip(self, dims=[dim]))
Exemple #16
0
def bmm(x, y):

    return Tensor(paddle.bmm(x, y))
Exemple #17
0
def linspace(start, stop, num, dtype="float32"):
    return Tensor(fluid.layers.linspace(start, stop, num, dtype))
Exemple #18
0
def eye(n, m):
    return Tensor(paddle.eye(n, m))
Exemple #19
0
def LongTensor(x):
    if isinstance(x, int):
        return Tensor(fluid.Tensor)
    if isinstance(x, list):
        x = np.array(x, dtype=np.int32)
    return Tensor(x)
Exemple #20
0
def dot(x, y):
    return Tensor(paddle.dot(x, y))
Exemple #21
0
def trace(x, offset=0, dim1=0, dim2=1, out=None):
    return Tensor(fluid.layers.trace(x, offset, dim1, dim2, out))
Exemple #22
0
def squeeze(x, axes=[-1]):
    return Tensor(paddle.squeeze(x, axes))
Exemple #23
0
def eye(n, m):
    return Tensor(fluid.layers.eye(n, m))
Exemple #24
0
def matmul(x, y):
    return Tensor(paddle.matmul(x, y))
Exemple #25
0
def tanh(x):
    return Tensor(fluid.layers.tanh(x))
Exemple #26
0
def full_like(x, fill_value):
    return Tensor.new_full(x, x.shape, fill_value)
Exemple #27
0
def squeeze(x, axes=[-1]):
    return Tensor(fluid.layers.squeeze(x, axes))
Exemple #28
0
def norm(input, p="fro", dim=None, keepdim=False, out=None, dtype=None):
    from . import linalg
    return Tensor(linalg.norm(input, p=p, axis=dim, keepdim=keepdim,
                              name=None))
Exemple #29
0
def tensor(x, dtype=np.float32):
    if isinstance(x, list):
        x = np.array(x, dtype=dtype)
    if isinstance(x, int) or isinstance(x, np.int64):
        return zeros(x)
    return Tensor(x)
Exemple #30
0
def randint(low, high, size=[1], dtype="int32", requires_grad=False):
    return Tensor(
        paddle.randint(low=low, high=high, shape=size, dtype=dtype, name=None))