diff --git a/doc/fluid/api_cn/dygraph_cn/Flatten_cn.rst b/doc/fluid/api_cn/dygraph_cn/Flatten_cn.rst index 92a9931d7faaa840361cd468205d68a1100f0911..e4ec73bca2b440154b7e8d7a3721808b1bbd8694 100644 --- a/doc/fluid/api_cn/dygraph_cn/Flatten_cn.rst +++ b/doc/fluid/api_cn/dygraph_cn/Flatten_cn.rst @@ -26,12 +26,13 @@ Flatten .. code-block:: python import paddle - from paddle.imperative import to_variable + from paddle import to_variable import numpy as np + inp_np = np.ones([5, 2, 3, 4]).astype('float32') - - paddle.enable_imperative() - + + paddle.disable_static() + inp_np = to_variable(inp_np) flatten = paddle.nn.Flatten(start_axis=1, stop_axis=2) flatten_res = flatten(inp_np) diff --git a/doc/fluid/api_cn/tensor_cn/addmm_cn.rst b/doc/fluid/api_cn/tensor_cn/addmm_cn.rst index bc7c3667b272c4f5461f9adf781d7be92d535d7f..d3a5ad0adf5aa58a7efb56daf9d810677fc41b34 100644 --- a/doc/fluid/api_cn/tensor_cn/addmm_cn.rst +++ b/doc/fluid/api_cn/tensor_cn/addmm_cn.rst @@ -37,14 +37,19 @@ addmm import numpy as np import paddle + data_x = np.ones((2, 2)).astype(np.float32) data_y = np.ones((2, 2)).astype(np.float32) data_input = np.ones((2, 2)).astype(np.float32) - paddle.enable_imperative() - x = paddle.imperative.to_variable(data_x) - y = paddle.imperative.to_variable(data_y) - input = paddle.imperative.to_variable(data_input) + + paddle.disable_static() + + x = paddle.to_variable(data_x) + y = paddle.to_variable(data_y) + input = paddle.to_variable(data_input) + out = paddle.tensor.addmm( input=input, x=x, y=y, beta=0.5, alpha=5.0 ) + print( out.numpy() ) # [[10.5 10.5] # [10.5 10.5]] diff --git a/doc/fluid/api_cn/tensor_cn/bmm_cn.rst b/doc/fluid/api_cn/tensor_cn/bmm_cn.rst index 201d4dba3a5b4eafb1020e3a568dc89de0df12bd..5cff0fb757048f6b2832a45f59b821b763810afb 100644 --- a/doc/fluid/api_cn/tensor_cn/bmm_cn.rst +++ b/doc/fluid/api_cn/tensor_cn/bmm_cn.rst @@ -33,14 +33,16 @@ bmm .. code-block:: python import paddle + # In imperative mode: # size input1: (2, 2, 3) and input2: (2, 3, 2) input1 = np.array([[[1.0, 1.0, 1.0],[2.0, 2.0, 2.0]],[[3.0, 3.0, 3.0],[4.0, 4.0, 4.0]]]) input2 = np.array([[[1.0, 1.0],[2.0, 2.0],[3.0, 3.0]],[[4.0, 4.0],[5.0, 5.0],[6.0, 6.0]]]) - paddle.enable_imperative() + + paddle.disable_static() - x = paddle.imperative.to_variable(input1) - y = paddle.imperative.to_variable(input2) + x = paddle.to_variable(input1) + y = paddle.to_variable(input2) out = paddle.bmm(x, y) #output size: (2, 2, 2) #output value: diff --git a/doc/fluid/api_cn/tensor_cn/flatten_cn.rst b/doc/fluid/api_cn/tensor_cn/flatten_cn.rst index 0f9c2f2c6f051d95eca6de10831683638c066c74..f307f985ccb4589d0e99a735a76ba75adabba948 100644 --- a/doc/fluid/api_cn/tensor_cn/flatten_cn.rst +++ b/doc/fluid/api_cn/tensor_cn/flatten_cn.rst @@ -58,12 +58,14 @@ flatten op 根据给定的start_axis 和 stop_axis 将连续的维度展平 import paddle import numpy as np - paddle.enable_imperative() + + paddle.disable_static() + image_shape=(2, 3, 4, 4) x = np.arange(image_shape[0] * image_shape[1] * image_shape[2] * image_shape[3]).reshape(image_shape) / 100. x = x.astype('float32') - img = paddle.imperative.to_variable(x) + img = paddle.to_variable(x) out = paddle.flatten(img, start_axis=1, stop_axis=2) # out shape is [2, 12, 4] diff --git a/doc/fluid/api_cn/tensor_cn/tril_cn.rst b/doc/fluid/api_cn/tensor_cn/tril_cn.rst index 324589121d470992ae1843918ce3f117cce66ea8..890d4191d48736b9c090e9a37b43613a1dbb9fae 100644 --- a/doc/fluid/api_cn/tensor_cn/tril_cn.rst +++ b/doc/fluid/api_cn/tensor_cn/tril_cn.rst @@ -28,22 +28,27 @@ tril import numpy as np import paddle + data = np.arange(1, 13, dtype="int64").reshape(3,-1) # array([[ 1, 2, 3, 4], # [ 5, 6, 7, 8], # [ 9, 10, 11, 12]]) - paddle.enable_imperative() - x = paddle.imperative.to_variable(data) + + paddle.disable_static() + + x = paddle.to_variable(data) tril1 = paddle.tensor.tril(x) # array([[ 1, 0, 0, 0], # [ 5, 6, 0, 0], # [ 9, 10, 11, 0]]) + # example 2, positive diagonal value tril2 = paddle.tensor.tril(x, diagonal=2) # array([[ 1, 2, 3, 0], # [ 5, 6, 7, 8], # [ 9, 10, 11, 12]]) + # example 3, negative diagonal value tril3 = paddle.tensor.tril(x, diagonal=-1) # array([[ 0, 0, 0, 0], diff --git a/doc/fluid/api_cn/tensor_cn/triu_cn.rst b/doc/fluid/api_cn/tensor_cn/triu_cn.rst index 1d928f25fcbdabebe301864797b71d59f27e2efd..3742a98601ce263a8b2df7aef4bac6ec4911be7f 100644 --- a/doc/fluid/api_cn/tensor_cn/triu_cn.rst +++ b/doc/fluid/api_cn/tensor_cn/triu_cn.rst @@ -29,22 +29,27 @@ triu import numpy as np import paddle + data = np.arange(1, 13, dtype="int64").reshape(3,-1) # array([[ 1, 2, 3, 4], # [ 5, 6, 7, 8], # [ 9, 10, 11, 12]]) - paddle.enable_imperative() + + paddle.disable_static() + # example 1, default diagonal - x = paddle.imperative.to_variable(data) + x = paddle.to_variable(data) triu1 = paddle.tensor.triu(x) # array([[ 1, 2, 3, 4], # [ 0, 6, 7, 8], # [ 0, 0, 11, 12]]) + # example 2, positive diagonal value triu2 = paddle.tensor.triu(x, diagonal=2) # array([[0, 0, 3, 4], # [0, 0, 0, 8], # [0, 0, 0, 0]]) + # example 3, negative diagonal value triu3 = paddle.tensor.triu(x, diagonal=-1) # array([[ 1, 2, 3, 4],