Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
f4630304
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
5
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
23
列表
看板
标记
里程碑
合并请求
111
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FluidDoc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
23
Issue
23
列表
看板
标记
里程碑
合并请求
111
合并请求
111
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f4630304
编写于
8月 13, 2020
作者:
Y
yaoxuefeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update demo code test=develop
上级
ffc147d8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
17 deletion
+37
-17
doc/fluid/api_cn/dygraph_cn/Flatten_cn.rst
doc/fluid/api_cn/dygraph_cn/Flatten_cn.rst
+5
-4
doc/fluid/api_cn/tensor_cn/addmm_cn.rst
doc/fluid/api_cn/tensor_cn/addmm_cn.rst
+9
-4
doc/fluid/api_cn/tensor_cn/bmm_cn.rst
doc/fluid/api_cn/tensor_cn/bmm_cn.rst
+5
-3
doc/fluid/api_cn/tensor_cn/flatten_cn.rst
doc/fluid/api_cn/tensor_cn/flatten_cn.rst
+4
-2
doc/fluid/api_cn/tensor_cn/tril_cn.rst
doc/fluid/api_cn/tensor_cn/tril_cn.rst
+7
-2
doc/fluid/api_cn/tensor_cn/triu_cn.rst
doc/fluid/api_cn/tensor_cn/triu_cn.rst
+7
-2
未找到文件。
doc/fluid/api_cn/dygraph_cn/Flatten_cn.rst
浏览文件 @
f4630304
...
...
@@ -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)
...
...
doc/fluid/api_cn/tensor_cn/addmm_cn.rst
浏览文件 @
f4630304
...
...
@@ -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]]
doc/fluid/api_cn/tensor_cn/bmm_cn.rst
浏览文件 @
f4630304
...
...
@@ -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:
...
...
doc/fluid/api_cn/tensor_cn/flatten_cn.rst
浏览文件 @
f4630304
...
...
@@ -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]
...
...
doc/fluid/api_cn/tensor_cn/tril_cn.rst
浏览文件 @
f4630304
...
...
@@ -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],
...
...
doc/fluid/api_cn/tensor_cn/triu_cn.rst
浏览文件 @
f4630304
...
...
@@ -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],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录