示例#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))
示例#2
0
def rand(*shape):
    if isinstance(shape, int):
        shape = [shape]
    if isinstance(shape[0], Iterable):
        shape = shape[0]
    return Tensor(paddle.rand(shape))
示例#3
0
def matmul(x, y):
    return Tensor(fluid.layers.matmul(x, y))
示例#4
0
def dot(x, y):
    return Tensor(fluid.layers.dot(x, y))
示例#5
0
def sigmoid(x):
    return Tensor(fluid.layers.sigmoid(x))
示例#6
0
def bmm(x, y):
    return Tensor(fluid.layers.bmm(x, y))
示例#7
0
def arange(*args, **kwargs):
    return Tensor(np.arange(*args, **kwargs).astype("int32"))
示例#8
0
def flip(self, dim):
    return Tensor(paddle.flip(self, dims=[dim]))
示例#9
0
def trace(x, offset=0, dim1=0, dim2=1, out=None):
    return Tensor(paddle.trace(x, offset, dim1, dim2, out))
示例#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))
示例#11
0
def eye(n, m=None):
    if m is None:
        m = n
    return Tensor(paddle.eye(n, m))
示例#12
0
def from_numpy(x):
    return Tensor(x)
示例#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"))
示例#14
0
def floor(x):
    return Tensor(paddle.floor(x))
示例#15
0
def flip(self, dim):
    return Tensor(fluid.layers.flip(self, dims=[dim]))
示例#16
0
def bmm(x, y):

    return Tensor(paddle.bmm(x, y))
示例#17
0
def linspace(start, stop, num, dtype="float32"):
    return Tensor(fluid.layers.linspace(start, stop, num, dtype))
示例#18
0
def eye(n, m):
    return Tensor(paddle.eye(n, m))
示例#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)
示例#20
0
def dot(x, y):
    return Tensor(paddle.dot(x, y))
示例#21
0
def trace(x, offset=0, dim1=0, dim2=1, out=None):
    return Tensor(fluid.layers.trace(x, offset, dim1, dim2, out))
示例#22
0
def squeeze(x, axes=[-1]):
    return Tensor(paddle.squeeze(x, axes))
示例#23
0
def eye(n, m):
    return Tensor(fluid.layers.eye(n, m))
示例#24
0
def matmul(x, y):
    return Tensor(paddle.matmul(x, y))
示例#25
0
def tanh(x):
    return Tensor(fluid.layers.tanh(x))
示例#26
0
def full_like(x, fill_value):
    return Tensor.new_full(x, x.shape, fill_value)
示例#27
0
def squeeze(x, axes=[-1]):
    return Tensor(fluid.layers.squeeze(x, axes))
示例#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))
示例#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)
示例#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))