未验证 提交 7ce3cba7 编写于 作者: D Double_V 提交者: GitHub

Merge branch 'develop' into pool

.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}` .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY! !DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_grad: .. _api_paddle_grad:
grad grad
---- ----
.. autofunction:: paddle.fluid.dygraph.grad .. autofunction:: paddle.grad
:noindex: :noindex:
...@@ -29,12 +29,17 @@ paddle.nn ...@@ -29,12 +29,17 @@ paddle.nn
nn/clip_by_norm.rst nn/clip_by_norm.rst
nn/collect_fpn_proposals.rst nn/collect_fpn_proposals.rst
nn/cond.rst nn/cond.rst
nn/ConstantPad1d.rst
nn/ConstantPad2d.rst
nn/ConstantPad3d.rst
nn/continuous_value_model.rst nn/continuous_value_model.rst
nn/conv2d.rst nn/conv2d.rst
nn/conv2d_transpose.rst nn/conv2d_transpose.rst
nn/conv3d.rst nn/conv3d.rst
nn/conv3d_transpose.rst nn/conv3d_transpose.rst
nn/cosine_decay.rst nn/cosine_decay.rst
nn/cosine_similarity.rst
nn/CosineSimilarity.rst
nn/cross_entropy.rst nn/cross_entropy.rst
nn/data.rst nn/data.rst
nn/deformable_roi_pooling.rst nn/deformable_roi_pooling.rst
...@@ -87,6 +92,7 @@ paddle.nn ...@@ -87,6 +92,7 @@ paddle.nn
nn/logsigmoid.rst nn/logsigmoid.rst
nn/loss.rst nn/loss.rst
nn/lrn.rst nn/lrn.rst
nn/margin_rank_loss.rst
nn/matrix_nms.rst nn/matrix_nms.rst
nn/maxout.rst nn/maxout.rst
nn/mse_loss.rst nn/mse_loss.rst
...@@ -111,9 +117,14 @@ paddle.nn ...@@ -111,9 +117,14 @@ paddle.nn
nn/psroi_pool.rst nn/psroi_pool.rst
nn/random_crop.rst nn/random_crop.rst
nn/rank_loss.rst nn/rank_loss.rst
nn/ReflectionPad1d.rst
nn/ReflectionPad2d.rst
nn/ReLU.rst nn/ReLU.rst
nn/relu.rst nn/relu.rst
nn/relu6.rst nn/relu6.rst
nn/ReplicationPad1d.rst
nn/ReplicationPad2d.rst
nn/ReplicationPad3d.rst
nn/resize_bilinear.rst nn/resize_bilinear.rst
nn/resize_nearest.rst nn/resize_nearest.rst
nn/resize_trilinear.rst nn/resize_trilinear.rst
...@@ -144,7 +155,7 @@ paddle.nn ...@@ -144,7 +155,7 @@ paddle.nn
nn/ssd_loss.rst nn/ssd_loss.rst
nn/swish.rst nn/swish.rst
nn/switch_case.rst nn/switch_case.rst
nn/tanh_shrink.rst nn/tanhshrink.rst
nn/target_assign.rst nn/target_assign.rst
nn/teacher_student_sigmoid_loss.rst nn/teacher_student_sigmoid_loss.rst
nn/temporal_shift.rst nn/temporal_shift.rst
...@@ -157,6 +168,7 @@ paddle.nn ...@@ -157,6 +168,7 @@ paddle.nn
nn/functional/loss/margin_ranking_loss.rst nn/functional/loss/margin_ranking_loss.rst
nn/functional/activation/sigmoid.rst nn/functional/activation/sigmoid.rst
nn/layer/loss/MarginRankingLoss.rst nn/layer/loss/MarginRankingLoss.rst
nn/ZeroPad2d.rst
nn/AdaptiveAvgPool2d.rst nn/AdaptiveAvgPool2d.rst
nn/AdaptiveAvgPool3d.rst nn/AdaptiveAvgPool3d.rst
nn/layer/activation/Sigmoid.rst nn/layer/activation/Sigmoid.rst
\ No newline at end of file
.. _api_nn_tanh_shrink: .. _api_nn_ConstantPad1d:
tanh_shrink ConstantPad1d
------------------------------- -------------------------------
:doc_source: paddle.fluid.layers.tanh_shrink :doc_source: paddle.nn.ConstantPad1d
.. _api_nn_ConstantPad2d:
ConstantPad2d
-------------------------------
:doc_source: paddle.nn.ConstantPad2d
.. _api_nn_ConstantPad3d:
ConstantPad3d
-------------------------------
:doc_source: paddle.nn.ConstantPad3d
.. _api_nn_CosineSimilarity:
CosineSimilarity
-------------------------------
:doc_source: paddle.nn.CosineSimilarity
.. _api_nn_ReflectionPad1d:
ReflectionPad1d
-------------------------------
:doc_source: paddle.nn.ReflectionPad1d
.. _api_nn_ReflectionPad2d:
ReflectionPad2d
-------------------------------
:doc_source: paddle.nn.ReflectionPad2d
.. _api_nn_ReplicationPad1d:
ReplicationPad1d
-------------------------------
:doc_source: paddle.nn.ReplicationPad1d
.. _api_nn_ReplicationPad2d:
ReplicationPad2d
-------------------------------
:doc_source: paddle.nn.ReplicationPad2d
.. _api_nn_ReplicationPad3d:
ReplicationPad3d
-------------------------------
:doc_source: paddle.nn.ReplicationPad3d
.. _cn_api_paddle_cn_clamp: .. _api_nn_ZeroPad2d:
clamp ZeroPad2d
------------------------------- -------------------------------
:doc_source: paddle.tensor.clamp :doc_source: paddle.nn.ZeroPad2d
...@@ -8,8 +8,15 @@ activation ...@@ -8,8 +8,15 @@ activation
activation/ELU.rst activation/ELU.rst
activation/GELU.rst activation/GELU.rst
activation/Hardshrink.rst activation/Hardshrink.rst
activation/Tanh.rst
activation/Hardtanh.rst activation/Hardtanh.rst
activation/LogSigmoid.rst
activation/PReLU.rst activation/PReLU.rst
activation/ReLU.rst activation/ReLU.rst
activation/LogSigmoid.rst activation/ReLU6.rst
activation/SELU.rst
activation/Softmax.rst activation/Softmax.rst
activation/Softplus.rst
activation/Softshrink.rst
activation/Softsign.rst
activation/Tanhshrink.rst
.. _api_nn_activation_ReLU6:
ReLU6
---------
.. autoclass:: paddle.nn.ReLU6
:noindex:
.. _api_nn_activation_SELU:
SELU
---------
.. autoclass:: paddle.nn.SELU
:noindex:
.. _api_nn_activation_Softplus:
Softplus
---------
.. autoclass:: paddle.nn.Softplus
:noindex:
.. _api_nn_activation_Softshrink:
Softshrink
----------
.. autoclass:: paddle.nn.Softshrink
:noindex:
.. _api_nn_activation_Softsign:
Softsign
---------
.. autoclass:: paddle.nn.Softsign
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_activation_Tanh:
Tanh
---------
.. autoclass:: paddle.nn.layer.activation.Tanh
:members:
:inherited-members:
:noindex:
.. _api_nn_activation_Tanhshrink:
Tanhshrink
----------
.. autoclass:: paddle.nn.Tanhshrink
:noindex:
.. _api_nn_cosine_similarity:
cosine_similarity
-------------------------------
:doc_source: paddle.nn.functional.cosine_similarity
...@@ -8,5 +8,6 @@ functional ...@@ -8,5 +8,6 @@ functional
functional/l1_loss.rst functional/l1_loss.rst
functional/nll_loss.rst functional/nll_loss.rst
functional/mse_loss.rst functional/mse_loss.rst
functional/ctc_loss.rst
functional/adaptive_avg_pool2d.rst functional/adaptive_avg_pool2d.rst
functional/adaptive_avg_pool3d.rst functional/adaptive_avg_pool3d.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_functional_binary_cross_entropy:
binary_cross_entropy
--------------------
.. autofunction:: paddle.nn.functional.binary_cross_entropy
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_functional_ctc_loss:
ctc_loss
--------
.. autofunction:: paddle.nn.functional.loss.ctc_loss
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_leaky_relu: .. _api_nn_leaky_relu:
leaky_relu leaky_relu
------------------------------- ----------
:doc_source: paddle.fluid.layers.leaky_relu
.. autofunction:: paddle.nn.functional.leaky_relu
:noindex:
...@@ -10,3 +10,4 @@ loss ...@@ -10,3 +10,4 @@ loss
loss/L1Loss.rst loss/L1Loss.rst
loss/MSELoss.rst loss/MSELoss.rst
loss/NLLLoss.rst loss/NLLLoss.rst
loss/CTCLoss.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_loss_BCELoss:
BCELoss
-------------------------------
.. autoclass:: paddle.nn.loss.BCELoss
:members:
:inherited-members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_nn_loss_CTCLoss:
CTCLoss
-------
.. autoclass:: paddle.nn.loss.CTCLoss
:members:
:inherited-members:
:noindex:
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
pad pad
------------------------------- -------------------------------
:doc_source: paddle.fluid.layers.pad :doc_source: paddle.nn.functional.pad
.. _api_nn_relu: .. _api_nn_ReLU:
relu ReLU
------------------------------- -------------------------------
:doc_source: paddle.fluid.layers.relu
.. autofunction:: paddle.nn.functional.relu
:noindex:
\ No newline at end of file
.. _api_nn_relu6: .. _api_nn_relu6:
relu6 relu6
------------------------------- ----------
:doc_source: paddle.fluid.layers.relu6
.. autofunction:: paddle.nn.functional.relu6
:noindex:
.. _api_nn_selu: .. _api_nn_selu:
selu selu
------------------------------- ----------
:doc_source: paddle.fluid.layers.selu
.. autofunction:: paddle.nn.functional.selu
:noindex:
.. _api_nn_softplus: .. _api_nn_softplus:
softplus softplus
------------------------------- ----------
:doc_source: paddle.fluid.layers.softplus
.. autofunction:: paddle.nn.functional.softplus
:noindex:
.. _api_nn_softshrink: .. _api_nn_softshrink:
softshrink softshrink
------------------------------- ----------
:doc_source: paddle.fluid.layers.softshrink
.. autofunction:: paddle.nn.functional.softshrink
:noindex:
.. _api_nn_softsign: .. _api_nn_softsign:
softsign softsign
------------------------------- ----------
:doc_source: paddle.fluid.layers.softsign
.. autofunction:: paddle.nn.functional.softsign
:noindex:
.. _api_nn_tanhshrink:
tanhshrink
-----------
.. autofunction:: paddle.nn.functional.tanhshrink
:noindex:
...@@ -23,6 +23,7 @@ paddle ...@@ -23,6 +23,7 @@ paddle
paddle/cast.rst paddle/cast.rst
paddle/ceil.rst paddle/ceil.rst
paddle/cholesky.rst paddle/cholesky.rst
paddle/chunk.rst
paddle/clamp.rst paddle/clamp.rst
paddle/CompiledProgram.rst paddle/CompiledProgram.rst
paddle/concat.rst paddle/concat.rst
...@@ -41,6 +42,7 @@ paddle ...@@ -41,6 +42,7 @@ paddle
paddle/diag.rst paddle/diag.rst
paddle/disable_imperative.rst paddle/disable_imperative.rst
paddle/dist.rst paddle/dist.rst
paddle/distribution.rst
paddle/div.rst paddle/div.rst
paddle/dot.rst paddle/dot.rst
paddle/elementwise_add.rst paddle/elementwise_add.rst
...@@ -111,6 +113,7 @@ paddle ...@@ -111,6 +113,7 @@ paddle
paddle/not_equal.rst paddle/not_equal.rst
paddle/ones.rst paddle/ones.rst
paddle/ones_like.rst paddle/ones_like.rst
paddle/numel.rst
paddle/ParallelExecutor.rst paddle/ParallelExecutor.rst
paddle/ParamAttr.rst paddle/ParamAttr.rst
paddle/pow.rst paddle/pow.rst
......
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_paddle_argmax: .. _api_paddle_argmax:
argmax argmax
------------------------------- ------
:doc_source: paddle.fluid.layers.argmax
.. autofunction:: paddle.tensor.search.argmax
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_paddle_argmin: .. _api_paddle_argmin:
argmin argmin
------------------------------- ------
:doc_source: paddle.fluid.layers.argmin
.. autofunction:: paddle.tensor.search.argmin
:noindex:
============
distribution
============
.. toctree::
:maxdepth: 1
distribution/Distribution.rst
distribution/Normal.rst
distribution/Uniform.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_distribution_Distribution:
Distribution
------------
.. autoclass:: paddle.distribution.Distribution
:members:
:inherited-members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_distribution_Normal:
Normal
------
.. autoclass:: paddle.distribution.Normal
:members:
:inherited-members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_distribution_Uniform:
Uniform
-------
.. autoclass:: paddle.distribution.Uniform
:members:
:inherited-members:
:noindex:
...@@ -16,6 +16,7 @@ paddle.tensor ...@@ -16,6 +16,7 @@ paddle.tensor
tensor/atan.rst tensor/atan.rst
tensor/cast.rst tensor/cast.rst
tensor/ceil.rst tensor/ceil.rst
tensor/chunk.rst
tensor/concat.rst tensor/concat.rst
tensor/cos.rst tensor/cos.rst
tensor/create_tensor.rst tensor/create_tensor.rst
...@@ -49,7 +50,10 @@ paddle.tensor ...@@ -49,7 +50,10 @@ paddle.tensor
tensor/has_nan.rst tensor/has_nan.rst
tensor/increment.rst tensor/increment.rst
tensor/is_empty.rst tensor/is_empty.rst
tensor/index_select.rst
tensor/isfinite.rst tensor/isfinite.rst
tensor/isinf.rst
tensor/isnan.rst
tensor/less_equal.rst tensor/less_equal.rst
tensor/less_than.rst tensor/less_than.rst
tensor/logic.rst tensor/logic.rst
...@@ -74,6 +78,7 @@ paddle.tensor ...@@ -74,6 +78,7 @@ paddle.tensor
tensor/not_equal.rst tensor/not_equal.rst
tensor/ones.rst tensor/ones.rst
tensor/ones_like.rst tensor/ones_like.rst
tensor/numel.rst
tensor/pow.rst tensor/pow.rst
tensor/random.rst tensor/random.rst
tensor/rank.rst tensor/rank.rst
...@@ -108,6 +113,7 @@ paddle.tensor ...@@ -108,6 +113,7 @@ paddle.tensor
tensor/squeeze.rst tensor/squeeze.rst
tensor/stack.rst tensor/stack.rst
tensor/stanh.rst tensor/stanh.rst
tensor/std.rst
tensor/stat.rst tensor/stat.rst
tensor/strided_slice.rst tensor/strided_slice.rst
tensor/sum.rst tensor/sum.rst
...@@ -119,6 +125,7 @@ paddle.tensor ...@@ -119,6 +125,7 @@ paddle.tensor
tensor/unique_with_counts.rst tensor/unique_with_counts.rst
tensor/unsqueeze.rst tensor/unsqueeze.rst
tensor/unstack.rst tensor/unstack.rst
tensor/var.rst
tensor/where.rst tensor/where.rst
tensor/zeros.rst tensor/zeros.rst
tensor/zeros_like.rst tensor/zeros_like.rst
.. _api_tensor_cn_argmax: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_argmax:
argmax argmax
------------------------------- ------
:doc_source: paddle.fluid.layers.argmax
.. autofunction:: paddle.tensor.search.argmax
:noindex:
.. _api_tensor_cn_argmin: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_argmin:
argmin argmin
------------------------------- ------
:doc_source: paddle.fluid.layers.argmin
.. autofunction:: paddle.tensor.search.argmin
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_chunk:
chunk
---
.. autofunction:: paddle.tensor.chunk
:noindex:
.. _api_tensor_cn_concat: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_concat:
concat concat
------------------------------- --------
:doc_source: paddle.fluid.layers.concat
.. autofunction:: paddle.tensor.concat
:noindex:
.. _api_tensor_cn_eye: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_eye:
eye eye
------------------------------- --------
:doc_source: paddle.fluid.layers.eye
.. autofunction:: paddle.tensor.full
:noindex:
.. _api_tensor_cn_full: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
full .. _api_tensor_full:
-------------------------------
:doc_source: paddle.fluid.layers.fill_constant
full
--------
.. autofunction:: paddle.tensor.full
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_index_select:
index_select
-------------
.. autofunction:: paddle.tensor.index_select
:noindex:
.. _api_tensor_cn_isfinite: .. _api_tensor_isfinite:
isfinite isfinite
------------------------------- -------------------------------
:doc_source: paddle.fluid.layers.isfinite
.. autofunction:: paddle.tensor.math.isfinite
:noindex:
.. _api_tensor_isinf:
isinf
-------------------------------
.. autofunction:: paddle.tensor.math.isinf
:noindex:
.. _api_tensor_isnan:
isnan
-------------------------------
.. autofunction:: paddle.tensor.math.isnan
:noindex:
.. _api_tensor_cn_linspace: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_linspace:
linspace linspace
------------------------------- --------
:doc_source: paddle.fluid.layers.linspace
.. autofunction:: paddle.tensor.linspace
:noindex:
...@@ -10,7 +10,11 @@ math ...@@ -10,7 +10,11 @@ math
math/addmm.rst math/addmm.rst
math/atan.rst math/atan.rst
math/clamp.rst math/clamp.rst
math/div.rst math/divide.rst
math/floor_divide.rst
math/remainder.rst
math/floor_mod.rst
math/mod.rst
math/elementwise_sum.rst math/elementwise_sum.rst
math/log1p.rst math/log1p.rst
math/logsumexp.rst math/logsumexp.rst
...@@ -19,6 +23,8 @@ math ...@@ -19,6 +23,8 @@ math
math/mm.rst math/mm.rst
math/mul.rst math/mul.rst
math/pow.rst math/pow.rst
math/prod.rst
math/sign.rst
math/sin.rst math/sin.rst
math/sqrt.rst math/sqrt.rst
math/sum.rst math/sum.rst
......
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_divide:
divide
------
.. autofunction:: paddle.tensor.math.divide
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_floor_divide:
floor_divide
------------
.. autofunction:: paddle.tensor.math.floor_divide
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_floor_mod:
floor_mod
---------
.. autofunction:: paddle.tensor.math.floor_mod
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_logsumexp:
logsumexp
---------
.. autofunction:: paddle.tensor.math.logsumexp
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_mod:
mod
---
.. autofunction:: paddle.tensor.math.mod
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_prod:
prod
----
.. autofunction:: paddle.tensor.math.prod
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_remainder:
remainder
---------
.. autofunction:: paddle.tensor.math.remainder
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_sign:
sign
------
.. autofunction:: paddle.tensor.math.sign
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_numel:
numel
-------
.. autofunction:: paddle.tensor.numel
:noindex:
.. _api_tensor_cn_ones: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_ones:
ones ones
------------------------------- --------
:doc_source: paddle.fluid.layers.ones
.. autofunction:: paddle.tensor.ones
:noindex:
...@@ -5,7 +5,10 @@ random ...@@ -5,7 +5,10 @@ random
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
random/normal.rst
random/rand.rst random/rand.rst
random/randint.rst random/randint.rst
random/randn.rst random/randn.rst
random/randperm.rst random/randperm.rst
random/standard_normal.rst
random/uniform.rst
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_random_normal:
normal
------
.. autofunction:: paddle.tensor.random.normal
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_random_standard_normal:
standard_normal
---------------
.. autofunction:: paddle.tensor.random.standard_normal
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_random_uniform:
uniform
-------
.. autofunction:: paddle.tensor.random.uniform
:noindex:
.. _api_tensor_cn_split: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_split:
split split
------------------------------- --------
:doc_source: paddle.fluid.layers.split
.. autofunction:: paddle.tensor.split
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_std:
std
---------
.. autofunction:: paddle.tensor.std
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_var:
var
---------
.. autofunction:: paddle.tensor.var
:noindex:
.. _api_tensor_cn_zeros: .. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_zeros:
zeros zeros
------------------------------- --------
:doc_source: paddle.fluid.layers.zeros
.. autofunction:: paddle.tensor.zeros
:noindex:
.. _cn_api_fluid_dygraph_grad: .. _cn_api_paddle_grad:
grad grad
------------------------------- -------------------------------
**注意:该API仅支持【动态图】模式** **注意:该API仅支持【动态图】模式**
.. py:method:: paddle.fluid.dygraph.grad(outputs, inputs, grad_outputs=None, retain_graph=None, create_graph=False, only_inputs=True, allow_unused=False, no_grad_vars=None, backward_strategy=None) .. py:method:: paddle.grad(outputs, inputs, grad_outputs=None, retain_graph=None, create_graph=False, only_inputs=True, allow_unused=False, no_grad_vars=None, backward_strategy=None)
对于每个 `inputs` ,计算所有 `outputs` 相对于其的梯度和。 对于每个 `inputs` ,计算所有 `outputs` 相对于其的梯度和。
...@@ -27,34 +27,34 @@ grad ...@@ -27,34 +27,34 @@ grad
**示例代码 1** **示例代码 1**
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle
paddle.disable_static()
def test_dygraph_grad(create_graph): def test_dygraph_grad(create_graph):
with fluid.dygraph.guard(): x = paddle.ones(shape=[1], dtype='float32')
x = fluid.layers.ones(shape=[1], dtype='float32') x.stop_gradient = False
x.stop_gradient = False y = x * x
y = x * x
# Since y = x * x, dx = 2 * x # Since y = x * x, dx = 2 * x
dx = fluid.dygraph.grad( dx = paddle.grad(
outputs=[y], outputs=[y],
inputs=[x], inputs=[x],
create_graph=create_graph, create_graph=create_graph,
retain_graph=True)[0] retain_graph=True)[0]
z = y + dx z = y + dx
# If create_graph = False, the gradient of dx # If create_graph = False, the gradient of dx
# would not be backpropagated. Therefore, # would not be backpropagated. Therefore,
# z = x * x + dx, and x.gradient() = 2 * x = 2.0 # z = x * x + dx, and x.gradient() = 2 * x = 2.0
# If create_graph = True, the gradient of dx # If create_graph = True, the gradient of dx
# would be backpropagated. Therefore, # would be backpropagated. Therefore,
# z = x * x + dx = x * x + 2 * x, and # z = x * x + dx = x * x + 2 * x, and
# x.gradient() = 2 * x + 2 = 4.0 # x.gradient() = 2 * x + 2 = 4.0
z.backward() z.backward()
return x.gradient() return x.gradient()
print(test_dygraph_grad(create_graph=False)) # [2.] print(test_dygraph_grad(create_graph=False)) # [2.]
print(test_dygraph_grad(create_graph=True)) # [4.] print(test_dygraph_grad(create_graph=True)) # [4.]
...@@ -62,16 +62,15 @@ grad ...@@ -62,16 +62,15 @@ grad
**示例代码 2** **示例代码 2**
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle
paddle.disable_static()
fluid.enable_dygraph()
def test_dygraph_grad(grad_outputs=None): def test_dygraph_grad(grad_outputs=None):
x = fluid.layers.fill_constant(shape=[1], value=2.0, dtype='float32') x = paddle.fill_constant(shape=[1], value=2.0, dtype='float32')
x.stop_gradient = False x.stop_gradient = False
y1 = x * x y1 = x * x
y2 = x * 3 y2 = x * 3
# If grad_outputs=None, dy1 = [1], dy2 = [1]. # If grad_outputs=None, dy1 = [1], dy2 = [1].
# If grad_outputs=[g1, g2], then: # If grad_outputs=[g1, g2], then:
...@@ -83,24 +82,24 @@ grad ...@@ -83,24 +82,24 @@ grad
# Therefore, the final result would be: # Therefore, the final result would be:
# dx = 2 * x * dy1 + 3 * dy2 = 4 * dy1 + 3 * dy2. # dx = 2 * x * dy1 + 3 * dy2 = 4 * dy1 + 3 * dy2.
dx = fluid.dygraph.grad( dx = paddle.grad(
outputs=[y1, y2], outputs=[y1, y2],
inputs=[x], inputs=[x],
grad_outputs=grad_outputs)[0] grad_outputs=grad_outputs)[0]
return dx.numpy() return dx.numpy()
THREE = fluid.layers.fill_constant(shape=[1], value=3.0, dtype='float32') grad_value = paddle.fill_constant(shape=[1], value=4.0, dtype='float32')
FOUR = fluid.layers.fill_constant(shape=[1], value=4.0, dtype='float32')
# dy1 = [1], dy2 = [1] # dy1 = [1], dy2 = [1]
print(test_dygraph_grad(None)) # [7.] print(test_dygraph_grad(None)) # [7.]
# dy1 = [1], dy2 = [4] # dy1 = [1], dy2 = [4]
print(test_dygraph_grad([None, FOUR])) # [16.] print(test_dygraph_grad([None, grad_value])) # [16.]
# dy1 = [4], dy2 = [1] # dy1 = [4], dy2 = [1]
print(test_dygraph_grad([FOUR, None])) # [19.] print(test_dygraph_grad([grad_value, None])) # [19.]
# dy1 = [3], dy2 = [4] # dy1 = [3], dy2 = [4]
print(test_dygraph_grad([THREE, FOUR])) # [24.] grad_y1 = paddle.fill_constant(shape=[1], value=3.0, dtype='float32')
\ No newline at end of file print(test_dygraph_grad([grad_y1, grad_value])) # [24.]
\ No newline at end of file
...@@ -5,25 +5,23 @@ linspace ...@@ -5,25 +5,23 @@ linspace
.. py:function:: paddle.fluid.layers.linspace(start, stop, num, dtype=None, name=None) .. py:function:: paddle.fluid.layers.linspace(start, stop, num, dtype=None, name=None)
该OP返回一个Tensor,Tensor的值为在区间start和stop上均匀间隔的num个值,输出Tensor的长度为num。 该OP返回一个Tensor,Tensor的值为在区间start和stop上均匀间隔的num个值,输出Tensor的长度为num。
**注意:该OP不进行梯度计算** **注意:该OP不进行梯度计算**
参数: 参数:
- **start** (float|Tensor) – ``start`` 是区间开始的变量,可以是一个浮点标量,或是一个shape为[1]的Tensor,该Tensor的数据类型可以是float32或者是float64。 - **start** (int|float|Tensor) – ``start`` 是区间开始的变量,可以是一个浮点标量,或是一个shape为[1]的Tensor,该Tensor的数据类型可以是float32,float64,int32 或者int64。
- **stop** (float|Tensor) – ``end`` 是区间结束的变量,可以是一个浮点标量,或是一个shape为[1]的Tensor,该Tensor的数据类型可以是float32或者是float64。 - **stop** (int|float|Tensor) – ``stop`` 是区间结束的变量,可以是一个浮点标量,或是一个shape为[1]的Tensor,该Tensor的数据类型可以是float32,float64,int32或者int64。
- **num** (int|Tensor) – ``num`` 是给定区间内需要划分的区间数,可以是一个整型标量,或是一个shape为[1]的Tensor,该Tensor的数据类型需为int32。 - **num** (int|Tensor) – ``num`` 是给定区间内需要划分的区间数,可以是一个整型标量,或是一个shape为[1]的Tensor,该Tensor的数据类型需为int32。
- **dtype** (string, 可选) – 输出Tensor的数据类型,可以是float32或者是float64,如果dtype的数据类型为None,输出Tensor数据类型为float32。 - **dtype** (np.dtype|str, 可选) – 输出Tensor的数据类型,可以是float32,float64, int32或者int64。如果dtype的数据类型为None,输出Tensor数据类型为float32。
- **name** (str, 可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。 - **name** (str, 可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。
返回:表示等间隔划分结果的1-D Tensor,该Tensor的shape大小为 :math:`[num]` ,在mum为1的情况下,仅返回包含start元素值的Tensor。 返回:表示等间隔划分结果的1-D Tensor,该Tensor的shape大小为 :math:`[num]` ,在mum为1的情况下,仅返回包含start元素值的Tensor。
抛出异常: 抛出异常:
- ``TypeError`` - 当start或者stop的数据类型不是float32或者float64。 - ``TypeError`` - 当 ``start`` 或者 ``stop`` 的数据类型不是float32,float64, int32或者int64。
- ``TypeError`` - 当num的数据类型不是float32或者float64。 - ``TypeError`` - 当 ``dtype`` 的类型不是float32,float64,int32或者int64。
- ``TypeError`` - 当dtype的类型不是float32或者float64。 - ``TypeError`` - ``num`` 的类型必须是int当 ``num`` 不是Tensor的时候。
- ``TypeError`` - ``num`` 的数据类型必须是int32当 ``num`` 是Tensor的时候。
**代码示例**: **代码示例**:
......
...@@ -9,7 +9,7 @@ ones ...@@ -9,7 +9,7 @@ ones
参数: 参数:
- **shape** (tuple|list|Tensor) - 输出Tensor的形状, ``shape`` 的数据类型为int32或者int64。 - **shape** (tuple|list|Tensor) - 输出Tensor的形状, ``shape`` 的数据类型为int32或者int64。
- **dtype** (np.dtype|core.VarDesc.VarType|str) - 输出Tensor的数据类型,数据类型必须为bool、 float16、float32、float64、int32或int64。 - **dtype** (np.dtype|str) - 输出Tensor的数据类型,数据类型必须为bool、 float16、float32、float64、int32或int64。
- **force_cpu** (bool, 可选) – 是否强制将输出Tensor写入CPU内存。如果 ``force_cpu`` 为False,则将输出Tensor写入当前所在运算设备的内存,默认为False。 - **force_cpu** (bool, 可选) – 是否强制将输出Tensor写入CPU内存。如果 ``force_cpu`` 为False,则将输出Tensor写入当前所在运算设备的内存,默认为False。
返回:值全为1的Tensor,数据类型和 ``dtype`` 定义的类型一致。 返回:值全为1的Tensor,数据类型和 ``dtype`` 定义的类型一致。
......
...@@ -15,7 +15,7 @@ reduce_prod ...@@ -15,7 +15,7 @@ reduce_prod
参数: 参数:
- **input** (Variable)- 输入变量为多维Tensor或LoDTensor,支持数据类型为float32,float64,int32,int64。 - **input** (Variable)- 输入变量为多维Tensor或LoDTensor,支持数据类型为float32,float64,int32,int64。
- **dim** (list | int ,可选)- 求乘积运算的维度。如果为None,则计算所有元素的乘积并返回包含单个元素的Tensor变量,否则必须在 :math:`[−rank(input),rank(input)]` 范围内。如果 :math:`dim [i] <0` ,则维度将变为 :math:`rank+dim[i]` ,默认值为None。 - **dim** (int|list|tuple ,可选)- 求乘积运算的维度。如果为None,则计算所有元素的乘积并返回包含单个元素的Tensor变量,否则必须在 :math:`[−rank(input),rank(input)]` 范围内。如果 :math:`dim [i] <0` ,则维度将变为 :math:`rank+dim[i]` ,默认值为None。
- **keep_dim** (bool)- 是否在输出Tensor中保留减小的维度。如 keep_dim 为true,否则结果张量的维度将比输入张量小,默认值为False。 - **keep_dim** (bool)- 是否在输出Tensor中保留减小的维度。如 keep_dim 为true,否则结果张量的维度将比输入张量小,默认值为False。
- **name** (str , 可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。 - **name** (str , 可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。
......
...@@ -5,11 +5,6 @@ reshape ...@@ -5,11 +5,6 @@ reshape
.. py:function:: paddle.fluid.layers.reshape(x, shape, actual_shape=None, act=None, inplace=False, name=None) .. py:function:: paddle.fluid.layers.reshape(x, shape, actual_shape=None, act=None, inplace=False, name=None)
:alias_main: paddle.reshape
:alias: paddle.reshape,paddle.tensor.reshape,paddle.tensor.manipulation.reshape
:old_api: paddle.fluid.layers.reshape
该OP在保持输入 ``x`` 数据不变的情况下,改变 ``x`` 的形状。 该OP在保持输入 ``x`` 数据不变的情况下,改变 ``x`` 的形状。
...@@ -31,23 +26,24 @@ reshape ...@@ -31,23 +26,24 @@ reshape
2. 给定一个形状为[2,4,6]的三维张量x,目标形状为[2,3,-1,2],则将x变换为形状为[2,3,4,2]的4-D张量,且x的数据保持不变。在这种情况下,目标形状的一个维度被设置为-1,这个维度的值是从x的元素总数和剩余维度推断出来的。 2. 给定一个形状为[2,4,6]的三维张量x,目标形状为[2,3,-1,2],则将x变换为形状为[2,3,4,2]的4-D张量,且x的数据保持不变。在这种情况下,目标形状的一个维度被设置为-1,这个维度的值是从x的元素总数和剩余维度推断出来的。
3. 给定一个形状为[2,4,6]的三维张量x,目标形状为[-1,0,3,2],则将x变换为形状为[2,4,3,2]的4-D张量,且x的数据保持不变。在这种情况下,0对应位置的维度值将从x的对应维数中复制,-1对应位置的维度值由x的元素总数和剩余维度推断出来。 3. 给定一个形状为[2,4,6]的三维张量x,目标形状为[-1,0,3,2],则将x变换为形状为[2,4,3,2]的4-D张量,且x的数据保持不变。在这种情况下,0对应位置的维度值将从x的对应维数中复制,-1对应位置的维度值由x的元素总数和剩余维度推断出来。
**注意:参数** ``actual_shape`` **之后将被舍弃,只用参数** ``shape`` **来表示目标形状。** .. warning::
参数 ``actual_shape`` 之后将被舍弃,只用参数 ``shape`` 来表示目标形状。
参数: 参数:
- **x** (Variable)- 多维 ``Tensor`` 或 ``LoDTensor``,数据类型为 ``float32``,``float64``,``int32``,或 ``int64``。 - **x** (Tensor)- N-D ``Tensor``,数据类型为 ``float32``,``float64``,``int32``,或 ``int64``。
- **shape** (list|tuple|Variable)- 数据类型是 ``int32`` 。定义目标形状。目标形状最多只能有一个维度为-1。如果 ``shape`` 的类型是 list 或 tuple, 它的元素可以是整数或者形状为[1]的 ``Tensor`` 或 ``LoDTensor``。如果 ``shape`` 的类型是 ``Variable``,则是1-D的 ``Tensor`` 或 ``LoDTensor``。 - **shape** (list|tuple|Tensor)- 数据类型是 ``int32`` 。定义目标形状。目标形状最多只能有一个维度为-1。如果 ``shape`` 的类型是 list 或 tuple, 它的元素可以是整数或者形状为[1]的 ``Tensor``。如果 ``shape`` 的类型是 ``Tensor``,则是1-D的 ``Tensor``。
- **actual_shape** (Variable,可选)- 1-D ``Tensor`` 或 ``LoDTensor``,默认值:`None`。如果 ``actual_shape`` 被提供,``actual_shape`` 具有比 ``shape`` 更高的优先级,此时 ``shape`` 只能是整数列表或元组。更新提示:``actual_shape`` 在未来的版本中将被舍弃,并用 ``shape`` 代替。 - **actual_shape** (Tensor,可选)- 1-D ``Tensor``,默认值:`None`。如果 ``actual_shape`` 被提供,``actual_shape`` 具有比 ``shape`` 更高的优先级,此时 ``shape`` 只能是整数列表或元组。更新提示:``actual_shape`` 在未来的版本中将被舍弃,并用 ``shape`` 代替。
- **act** (str,可选)- 对形状改变后的输入变量做非线性激活操作,激活函数类型可以参考 :ref:`api_guide_activations` 。默认值: ``None``。 - **act** (str,可选)- 对形状改变后的输入变量做非线性激活操作,激活函数类型可以参考 :ref:`api_guide_activations` 。默认值: ``None``。
- **inplace** (bool,可选)- 如果 ``inplace`` 为 ``True``,则 ``layers.reshape`` 的输入和输出是同一个变量,否则 ``layers.reshape`` 的输入和输出是不同的变量。默认值:``False``。请注意,如果 ``x`` 是多个OP的输入,则 ``inplace`` 必须为False。 - **inplace** (bool,可选)- 如果 ``inplace`` 为 ``True``,则 ``layers.reshape`` 的输入和输出是同一个变量,否则 ``layers.reshape`` 的输入和输出是不同的变量。默认值:``False``。请注意,如果 ``x`` 是多个OP的输入,则 ``inplace`` 必须为False。
- **name** (str,可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置。默认值: ``None``。 - **name** (str,可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置。默认值: ``None``。
返回:多维 ``Tensor`` 或 ``LoDTensor``,数据类型与 ``input`` 相同。如果 ``inplace`` 为 ``False``,则返回一个新的变量,否则将改变输入变量 ``x`` 自身。如果 ``act`` 为 ``None``,则直接返回形状改变后的变量,否则返回经过激活函数后的变量。 返回:
:::::::::
返回类型:Variable ``Tensor``,改变形状后的 ``Tensor``,数据类型与 ``x`` 相同。如果 ``inplace`` 为 ``False``,则返回一个新的变量,否则将改变输入变量 ``x`` 自身。如果 ``act`` 为 ``None``,则直接返回形状改变后的变量,否则返回经过激活函数后的变量
抛出异常: 抛出异常:
- :code:`TypeError`:``actual_shape`` 的类型应该是 Variable 或 None。 - :code:`TypeError`:``actual_shape`` 的类型应该是 Tensor 或 None。
- :code:`TypeError`:``starts`` 的类型应该是list、tuple 或 Variable - :code:`TypeError`:``starts`` 的类型应该是list、tuple 或 Tensor
- :code:`ValueError`:``shape`` 中至多有一个元素可以是-1。 - :code:`ValueError`:``shape`` 中至多有一个元素可以是-1。
- :code:`ValueError`:``shape`` 中的元素为0时,对应的维度应该小于等于``x``的维度。 - :code:`ValueError`:``shape`` 中的元素为0时,对应的维度应该小于等于``x``的维度。
- :code:`ValueError`:``shape`` 中的元素除了-1之外,都应该是非负值。 - :code:`ValueError`:``shape`` 中的元素除了-1之外,都应该是非负值。
...@@ -59,7 +55,7 @@ reshape ...@@ -59,7 +55,7 @@ reshape
import paddle.fluid as fluid import paddle.fluid as fluid
# example 1: # example 1:
# attr shape is a list which doesn't contain tensor Variable. # attr shape is a list which doesn't contain Tensors.
data_1 = fluid.data( data_1 = fluid.data(
name='data_1', shape=[2, 4, 6], dtype='float32') name='data_1', shape=[2, 4, 6], dtype='float32')
reshaped_1 = fluid.layers.reshape( reshaped_1 = fluid.layers.reshape(
...@@ -67,7 +63,7 @@ reshape ...@@ -67,7 +63,7 @@ reshape
# the shape of reshaped_1 is [2,4,3,2]. # the shape of reshaped_1 is [2,4,3,2].
# example 2: # example 2:
# attr shape is a list which contains tensor Variable. # attr shape is a list which contains Tensors.
data_2 = fluid.layers.fill_constant([2,25], "int32", 3) data_2 = fluid.layers.fill_constant([2,25], "int32", 3)
dim = fluid.layers.fill_constant([1], "int32", 5) dim = fluid.layers.fill_constant([1], "int32", 5)
reshaped_2 = fluid.layers.reshape(data_2, shape=[dim, 10]) reshaped_2 = fluid.layers.reshape(data_2, shape=[dim, 10])
......
...@@ -5,12 +5,6 @@ sign ...@@ -5,12 +5,6 @@ sign
.. py:function:: paddle.fluid.layers.sign(x) .. py:function:: paddle.fluid.layers.sign(x)
:alias_main: paddle.sign
:alias: paddle.sign,paddle.tensor.sign,paddle.tensor.math.sign
:old_api: paddle.fluid.layers.sign
此OP对输入x中每个元素进行正负判断,并且输出正负判断值:1代表正,-1代表负,0代表零。 此OP对输入x中每个元素进行正负判断,并且输出正负判断值:1代表正,-1代表负,0代表零。
参数: 参数:
......
...@@ -9,7 +9,7 @@ zeros ...@@ -9,7 +9,7 @@ zeros
参数: 参数:
- **shape** (tuple|list|Tensor) - 输出Tensor的形状, ``shape`` 的数据类型为int32或者int64。 - **shape** (tuple|list|Tensor) - 输出Tensor的形状, ``shape`` 的数据类型为int32或者int64。
- **dtype** (np.dtype|core.VarDesc.VarType|str) - 输出Tensor的数据类型,数据类型必须为bool、 float16、float32、float64、int32或int64。 - **dtype** (np.dtype|str) - 输出Tensor的数据类型,数据类型必须为bool、 float16、float32、float64、int32或int64。
- **force_cpu** (bool, 可选) - 是否强制将输出Tensor写入CPU内存。如果 ``force_cpu`` 为False,则将输出Tensor写入当前所在运算设备的内存,默认为False。 - **force_cpu** (bool, 可选) - 是否强制将输出Tensor写入CPU内存。如果 ``force_cpu`` 为False,则将输出Tensor写入当前所在运算设备的内存,默认为False。
返回:值全为0的Tensor,数据类型和 ``dtype`` 定义的类型一致。 返回:值全为0的Tensor,数据类型和 ``dtype`` 定义的类型一致。
......
...@@ -48,7 +48,12 @@ paddle.nn ...@@ -48,7 +48,12 @@ paddle.nn
nn_cn/conv2d_transpose_cn.rst nn_cn/conv2d_transpose_cn.rst
nn_cn/conv3d_cn.rst nn_cn/conv3d_cn.rst
nn_cn/conv3d_transpose_cn.rst nn_cn/conv3d_transpose_cn.rst
nn_cn/ConstantPad1d_cn.rst
nn_cn/ConstantPad2d_cn.rst
nn_cn/ConstantPad3d_cn.rst
nn_cn/cosine_decay_cn.rst nn_cn/cosine_decay_cn.rst
nn_cn/cosine_similarity_cn.rst
nn_cn/CosineSimilarity_cn.rst
nn_cn/cross_entropy_cn.rst nn_cn/cross_entropy_cn.rst
nn_cn/data_cn.rst nn_cn/data_cn.rst
nn_cn/deformable_roi_pooling_cn.rst nn_cn/deformable_roi_pooling_cn.rst
...@@ -108,6 +113,7 @@ paddle.nn ...@@ -108,6 +113,7 @@ paddle.nn
nn_cn/one_hot_cn.rst nn_cn/one_hot_cn.rst
nn_cn/pad2d_cn.rst nn_cn/pad2d_cn.rst
nn_cn/pad_cn.rst nn_cn/pad_cn.rst
nn_cn/Pad_cn.rst
nn_cn/pad_constant_like_cn.rst nn_cn/pad_constant_like_cn.rst
nn_cn/PairwiseDistance_cn.rst nn_cn/PairwiseDistance_cn.rst
nn_cn/ParameterList_cn.rst nn_cn/ParameterList_cn.rst
...@@ -124,11 +130,16 @@ paddle.nn ...@@ -124,11 +130,16 @@ paddle.nn
nn_cn/psroi_pool_cn.rst nn_cn/psroi_pool_cn.rst
nn_cn/random_crop_cn.rst nn_cn/random_crop_cn.rst
nn_cn/rank_loss_cn.rst nn_cn/rank_loss_cn.rst
nn_cn/ReflectionPad1d_cn.rst
nn_cn/ReflectionPad2d_cn.rst
nn_cn/relu6_cn.rst nn_cn/relu6_cn.rst
nn_cn/relu_cn.rst nn_cn/relu_cn.rst
nn_cn/resize_bilinear_cn.rst nn_cn/resize_bilinear_cn.rst
nn_cn/resize_nearest_cn.rst nn_cn/resize_nearest_cn.rst
nn_cn/resize_trilinear_cn.rst nn_cn/resize_trilinear_cn.rst
nn_cn/ReplicationPad1d_cn.rst
nn_cn/ReplicationPad2d_cn.rst
nn_cn/ReplicationPad3d_cn.rst
nn_cn/retinanet_detection_output_cn.rst nn_cn/retinanet_detection_output_cn.rst
nn_cn/retinanet_target_assign_cn.rst nn_cn/retinanet_target_assign_cn.rst
nn_cn/roi_align_cn.rst nn_cn/roi_align_cn.rst
...@@ -156,7 +167,7 @@ paddle.nn ...@@ -156,7 +167,7 @@ paddle.nn
nn_cn/ssd_loss_cn.rst nn_cn/ssd_loss_cn.rst
nn_cn/swish_cn.rst nn_cn/swish_cn.rst
nn_cn/switch_case_cn.rst nn_cn/switch_case_cn.rst
nn_cn/tanh_shrink_cn.rst nn_cn/tanhshrink_cn.rst
nn_cn/target_assign_cn.rst nn_cn/target_assign_cn.rst
nn_cn/teacher_student_sigmoid_loss_cn.rst nn_cn/teacher_student_sigmoid_loss_cn.rst
nn_cn/temporal_shift_cn.rst nn_cn/temporal_shift_cn.rst
...@@ -174,4 +185,10 @@ paddle.nn ...@@ -174,4 +185,10 @@ paddle.nn
nn/cn/functional_cn/MaxPool3d_cn.rst nn/cn/functional_cn/MaxPool3d_cn.rst
nn_cn/AdaptiveAvgPool2d_cn.rst nn_cn/AdaptiveAvgPool2d_cn.rst
nn_cn/AdaptiveAvgPool3d_cn.rst nn_cn/AdaptiveAvgPool3d_cn.rst
nn_cn/Dropout_cn.rst
nn_cn/Dropout2D_cn.rst
nn_cn/Dropout3D_cn.rst
nn_cn/AlphaDropout_cn.rst
nn_cn/ZeroPad2d_cn.rst
nn_cn/AdaptiveAvgPool2d_cn.rst
nn_cn/AdaptiveAvgPool3d_cn.rst
.. _cn_api_nn_AlphaDropout:
AlphaDropout
-------------------------------
.. py:function:: paddle.nn.AlphaDropout(p=0.5, name=None)
AlphaDropout是一种具有自归一化性质的dropout。均值为0,方差为1的输入,经过AlphaDropout计算之后,输出的均值和方差与输入保持一致。AlphaDropout通常与SELU激活函数组合使用。论文请参考: `Self-Normalizing Neural Networks <https://arxiv.org/abs/1706.02515>`_
在动态图模式下,请使用模型的 `eval()` 方法切换至测试阶段。
.. note::
对应的 `functional方法` 请参考: :ref:`cn_api_nn_functional_alpha_dropout` 。
参数
:::::::::
- **p** (float): 将输入节点置0的概率,即丢弃概率。默认: 0.5。
- **name** (str,可选): 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
返回
:::::::::
经过AlphaDropout之后的结果,与输入x形状相同的 `Tensor` 。
代码示例
:::::::::
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
x = np.array([[-1, 1], [-1, 1]]).astype('float32')
x = paddle.to_tensor(x)
m = paddle.nn.AlphaDropout(p=0.5)
y_train = m(x)
m.eval() # switch the model to test phase
y_test = m(x)
print(x.numpy())
print(y_train.numpy())
# [[-0.10721093, 1.6655989 ], [-0.7791938, -0.7791938]] (randomly)
print(y_test.numpy())
.. _cn_api_nn_ConstantPad1d:
ConstantPad1d
-------------------------------
.. py:class:: paddle.nn.ConstantPad1d(padding, value=0.0, data_format="NCL", name=None)
**ConstantPad1d**
按照 padding 对输入 以constant模式进行 ``pad``,即填充固定值。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right]。
- **value** (float32) - 待填充的值,默认值为0.0。
- **data_format** (str) - 指定input的format,可为 `'NCL'` 或者 `'NLC'`,默认值为`'NCL'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 2, 3)
pad = [1, 2]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ConstantPad1d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[0. 1. 2. 3. 0. 0.]
# [0. 4. 5. 6. 0. 0.]]]
.. _cn_api_nn_ConstantPad2d:
ConstantPad2d
-------------------------------
.. py:class:: paddle.nn.ConstantPad2d(padding, value=0.0, data_format="NCHW", name=None)
**ConstantPad2d**
按照 padding 对输入 以constant模式进行 ``pad``,即填充固定值。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right, pad_top, pad_bottom]。
- **value** (float32) - 待填充的值,默认值为0.0。
- **data_format** (str) - 指定input的format,可为 `'NCHW'` 或者 `'NHWC'`,默认值为`'NCHW'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 1, 2, 3)
pad = [1, 0, 1, 2]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ConstantPad2d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[[0. 0. 0. 0.]
# [0. 1. 2. 3.]
# [0. 4. 5. 6.]
# [0. 0. 0. 0.]
# [0. 0. 0. 0.]]]]
.. _cn_api_nn_ConstantPad3d:
ConstantPad3d
-------------------------------
.. py:class:: paddle.nn.ConstantPad3d(padding, value=0.0, data_format="NCDHW", name=None)
**ConstantPad3d**
按照 padding 对输入 以constant模式进行 ``pad``,即填充固定值。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right, pad_top, pad_bottom, pad_front, pad_back]。
- **value** (float32) - 待填充的值,默认值为0.0。
- **data_format** (str) - 指定input的format,可为 `'NCDHW'` 或者 `'NDHWC'`,默认值为`'NCDHW'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 1, 1, 2, 3)
pad = [1, 0, 1, 2, 0, 0]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ConstantPad3d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[[[0. 0. 0. 0.]
# [0. 1. 2. 3.]
# [0. 4. 5. 6.]
# [0. 0. 0. 0.]
# [0. 0. 0. 0.]]]]]
.. _cn_api_nn_CosineSimilarity:
CosineSimilarity
-------------------------------
.. py:class:: paddle.nn.CosineSimilarity(axis=1, eps=1e-8)
**CosineSimilarity**
计算x1与x2沿axis维度的余弦相似度。
参数:
- **axis** (int) - 指定计算的维度,会在该维度上计算余弦相似度,默认值为1。
- **eps** (float) - 很小的值,防止计算时分母为0,默认值为1e-8。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
np.random.seed(0)
x1 = np.random.rand(2,3)
x2 = np.random.rand(2,3)
x1 = paddle.to_tensor(x1)
x2 = paddle.to_tensor(x2)
cos_sim_func = nn.CosineSimilarity(axis=0)
result = cos_sim_func(x1, x2)
print(result.numpy())
# [0.99806249 0.9817672 0.94987036]
.. _cn_api_nn_Dropout2D:
Dropout2D
-------------------------------
.. py:function:: paddle.nn.Dropout2D(p=0.5, data_format='NCHW', name=None)
根据丢弃概率 `p` ,在训练过程中随机将某些通道特征图置0(对一个形状为 `NCHW` 的4维张量,通道特征图指的是其中的形状为 `HW` 的2维特征图)。Dropout2D可以提高通道特征图之间的独立性。论文请参考: `Efficient Object Localization Using Convolutional Networks <https://arxiv.org/abs/1411.4280>`_
在动态图模式下,请使用模型的 `eval()` 方法切换至测试阶段。
.. note::
对应的 `functional方法` 请参考: :ref:`cn_api_nn_functional_dropout2d` 。
参数
:::::::::
- **p** (float): 将输入通道置0的概率, 即丢弃概率。默认: 0.5。
- **data_format** (str): 指定输入的数据格式,输出的数据格式将与输入保持一致,可以是 `NCHW` 和 `NHWC` 。其中 `N` 是批尺寸, `C` 是通道数, `H` 是特征高度, `W` 是特征宽度。默认值: `NCHW` 。
- **name** (str,可选): 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
形状
:::::::::
- **输入** : 4-D `Tensor` 。
- **输出** : 4-D `Tensor` ,形状与输入相同。
代码示例
:::::::::
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
x = np.random.random(size=(2, 3, 4, 5)).astype('float32')
x = paddle.to_tensor(x)
m = paddle.nn.Dropout2D(p=0.5)
y_train = m(x)
m.eval() # switch the model to test phase
y_test = m(x)
print(x.numpy())
print(y_train.numpy())
print(y_test.numpy())
.. _cn_api_nn_Dropout3D:
Dropout3D
-------------------------------
.. py:function:: paddle.nn.Dropout3D(p=0.5, data_format='NCDHW', name=None)
根据丢弃概率 `p` ,在训练过程中随机将某些通道特征图置0(对一个形状为 `NCDHW` 的5维张量,通道特征图指的是其中的形状为 `DHW` 的3维特征图)。Dropout3D可以提高通道特征图之间的独立性。论文请参考: `Efficient Object Localization Using Convolutional Networks <https://arxiv.org/abs/1411.4280>`_
在动态图模式下,请使用模型的 `eval()` 方法切换至测试阶段。
.. note::
对应的 `functional方法` 请参考: :ref:`cn_api_nn_functional_dropout3d` 。
参数
:::::::::
- **p** (float): 将输入通道置0的概率, 即丢弃概率。默认: 0.5。
- **data_format** (str): 指定输入的数据格式,输出的数据格式将与输入保持一致,可以是 `NCDHW` 和 `NDHWC` 。其中 `N` 是批尺寸, `C` 是通道数, `D` 是特征深度, `H` 是特征高度, `W` 是特征宽度。默认值: `NCDHW` 。
- **name** (str,可选): 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
形状
:::::::::
- **输入** : 5-D `Tensor` 。
- **输出** : 5-D `Tensor` ,形状与输入相同。
代码示例
:::::::::
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
x = np.random.random(size=(2, 3, 4, 5, 6)).astype('float32')
x = paddle.to_tensor(x)
m = paddle.nn.Dropout3D(p=0.5)
y_train = m(x)
m.eval() # switch the model to test phase
y_test = m(x)
print(x.numpy())
print(y_train.numpy())
print(y_test.numpy())
.. _cn_api_nn_Dropout:
Dropout
-------------------------------
.. py:function:: paddle.nn.Dropout(p=0.5, axis=None, mode="upscale_in_train”, name=None)
Dropout是一种正则化手段,该算子根据给定的丢弃概率 `p` ,在训练过程中随机将一些神经元输出设置为0,通过阻止神经元节点间的相关性来减少过拟合。论文请参考: `Improving neural networks by preventing co-adaptation of feature detectors <https://arxiv.org/abs/1207.0580>`_
在动态图模式下,请使用模型的 `eval()` 方法切换至测试阶段。
.. note::
对应的 `functional方法` 请参考: :ref:`cn_api_nn_functional_dropout` 。
参数
:::::::::
- **p** (float): 将输入节点置为0的概率, 即丢弃概率。默认: 0.5。
- **axis** (int|list): 指定对输入 `Tensor` 进行Dropout操作的轴。默认: None。
- **mode** (str): 丢弃单元的方式,有两种'upscale_in_train'和'downscale_in_infer',默认: 'upscale_in_train'。计算方法如下:
1. upscale_in_train, 在训练时增大输出结果。
- train: out = input * mask / ( 1.0 - p )
- inference: out = input
2. downscale_in_infer, 在预测时减小输出结果
- train: out = input * mask
- inference: out = input * (1.0 - p)
- **name** (str,可选): 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。
形状
:::::::::
- **输入** : N-D `Tensor` 。
- **输出** : N-D `Tensor` ,形状与输入相同。
代码示例
:::::::::
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
x = np.array([[1,2,3], [4,5,6]]).astype('float32')
x = paddle.to_tensor(x)
m = paddle.nn.Dropout(p=0.5)
y_train = m(x)
m.eval() # switch the model to test phase
y_test = m(x)
print(x.numpy())
print(y_train.numpy())
print(y_test.numpy())
.. _cn_api_nn_ReflectionPad1d:
ReflectionPad1d
-------------------------------
.. py:class:: paddle.nn.ReflectionPad1d(padding, data_format="NCL", name=None)
**ReflectionPad1d**
按照 padding 对输入 以reflection模式进行 ``pad``,即填充以输入边界值为轴的映射 。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right]。
- **data_format** (str) - 指定input的format,可为 `'NCL'` 或者 `'NLC'`,默认值为`'NCL'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 2, 3)
pad = [1, 2]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ReflectionPad1d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[2. 1. 2. 3. 2. 1.]
# [5. 4. 5. 6. 5. 4.]]]
.. _cn_api_nn_ReflectionPad2d:
ReflectionPad2d
-------------------------------
.. py:class:: paddle.nn.ReflectionPad2d(padding, data_format="NCHW", name=None)
**ReflectionPad2d**
按照 padding 对输入 以reflection模式进行 ``pad``,即填充以输入边界值为轴的映射 。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right, pad_top, pad_bottom]。。
- **data_format** (str) - 指定input的format,可为 `'NCHW'` 或者 `'NHWC'`,默认值为`'NCHW'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 1, 4, 3)
pad = [1, 0, 1, 2]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ReflectionPad2d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[[ 5. 4. 5. 6.]
# [ 2. 1. 2. 3.]
# [ 5. 4. 5. 6.]
# [ 8. 7. 8. 9.]
# [11. 10. 11. 12.]
# [ 8. 7. 8. 9.]
# [ 5. 4. 5. 6.]]]]
\ No newline at end of file
.. _cn_api_nn_ReplicationPad1d:
ReplicationPad1d
-------------------------------
.. py:class:: paddle.nn.ReplicationPad1d(padding, data_format="NCL", name=None)
**ReplicationPad1d**
按照 padding 对输入 以replicate模式进行 ``pad``,即填充输入的边界值。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right]。
- **data_format** (str) - 指定input的format,可为 `'NCL'` 或者 `'NLC'`,默认值为`'NCL'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 2, 3)
pad = [1, 2]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ReplicationPad1d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[1. 1. 2. 3. 3. 3.]
# [1. 4. 5. 6. 6. 6.]]]
.. _cn_api_nn_ReplicationPad2d:
ReplicationPad2d
-------------------------------
.. py:class:: paddle.nn.ReplicationPad2d(padding, data_format="NCHW", name=None)
**ReplicationPad2d**
按照 padding 对输入 以replicate模式进行 ``pad``,即填充输入的边界值。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right, pad_top, pad_bottom]。
- **data_format** (str) - 指定input的format,可为 `'NCHW'` 或者 `'NHWC'`,默认值为`'NCHW'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 1, 2, 3)
pad = [1, 0, 1, 2]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ReplicationPad2d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[[1. 1. 2. 3.]
# [1. 1. 2. 3.]
# [4. 4. 5. 6.]
# [4. 4. 5. 6.]
# [4. 4. 5. 6.]]]]
.. _cn_api_nn_ReplicationPad3d:
ReplicationPad3d
-------------------------------
.. py:class:: paddle.nn.ReplicationPad3d(padding, data_format="NCDHW", name=None)
**ReplicationPad3d**
按照 padding 对输入 以replicate模式进行 ``pad``,即填充输入的边界值。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right, pad_top, pad_bottom, pad_front, pad_back]。
- **data_format** (str) - 指定input的format,可为 `'NCDHW'` 或者 `'NDHWC'`,默认值为`'NCDHW'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 1, 1, 2, 3)
pad = [1, 0, 1, 2, 0, 0]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ReplicationPad3d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[[[1. 1. 2. 3.]
# [1. 1. 2. 3.]
# [4. 4. 5. 6.]
# [4. 4. 5. 6.]
# [4. 4. 5. 6.]]]]]
.. _cn_api_nn_ZeroPad2d:
ZeroPad2d
-------------------------------
.. py:class:: paddle.nn.ZeroPad2d(padding, data_format="NCHW", name=None)
**ZeroPad2d**
按照 padding 对输入填充固定值0。
参数:
- **padding** (Tensor | List[int32]) - 填充大小。pad的格式为[pad_left, pad_right, pad_top, pad_bottom]。
- **data_format** (str) - 指定input的format,可为 `'NCHW'` 或者 `'NHWC'`,默认值为`'NCHW'`。
- **name** (str, 可选) - 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,缺省值为None。
返回:无
**代码示例**
.. code-block:: python
import paddle
import paddle.nn as nn
import numpy as np
paddle.disable_static()
input_shape = (1, 1, 2, 3)
pad = [1, 0, 1, 2]
data = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) + 1
my_pad = nn.ZeroPad2d(padding=pad)
data = paddle.to_tensor(data)
result = my_pad(data)
print(result.numpy())
# [[[[0. 0. 0. 0.]
# [0. 1. 2. 3.]
# [0. 4. 5. 6.]
# [0. 0. 0. 0.]
# [0. 0. 0. 0.]]]]
...@@ -11,11 +11,18 @@ activation ...@@ -11,11 +11,18 @@ activation
activation_cn/ELU_cn.rst activation_cn/ELU_cn.rst
activation_cn/GELU_cn.rst activation_cn/GELU_cn.rst
activation_cn/Hardshrink_cn.rst activation_cn/Hardshrink_cn.rst
activation_cn/Tanh_cn.rst
activation_cn/Hardtanh_cn.rst activation_cn/Hardtanh_cn.rst
activation_cn/PRelu_cn.rst
activation_cn/ReLU_cn.rst
activation_cn/LeakyReLU_cn.rst activation_cn/LeakyReLU_cn.rst
activation_cn/Softmax_cn.rst activation_cn/LogSigmoid_cn.rst
activation_cn/LogSoftmax_cn.rst activation_cn/LogSoftmax_cn.rst
activation_cn/PRelu_cn.rst
activation_cn/ReLU_cn.rst
activation_cn/ReLU6_cn.rst
activation_cn/SELU_cn.rst
activation_cn/Sigmoid_cn.rst activation_cn/Sigmoid_cn.rst
activation_cn/LogSigmoid_cn.rst activation_cn/Softmax_cn.rst
activation_cn/Softplus_cn.rst
activation_cn/Softshrink_cn.rst
activation_cn/Softsign_cn.rst
activation_cn/Tanhshrink_cn.rst
...@@ -2,19 +2,25 @@ ...@@ -2,19 +2,25 @@
LeakyReLU LeakyReLU
------------------------------- -------------------------------
.. py:class:: paddle.nn.LeakyReLU(alpha=0.01, name=None) .. py:class:: paddle.nn.LeakyReLU(negative_slope=0.01, name=None)
ReLU (Rectified Linear Unit)激活层 LeakyReLU 激活层
.. math:: .. math::
\\Out = max(x, alpha*x)\\ LeakyReLU(x)=
\left\{
\begin{aligned}
&x, & & if \ x >= 0 \\
&negative\_slope * x, & & otherwise \\
\end{aligned}
\right. \\
其中,:math:`x` 为输入的 Tensor 其中,:math:`x` 为输入的 Tensor
参数 参数
:::::::::: ::::::::::
- alpha (float,可选) - :math:`x < 0` 时的斜率。默认值为0.01。 - negative_slope (float,可选) - :math:`x < 0` 时的斜率。默认值为0.01。
- name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 - name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。
形状: 形状:
...@@ -29,8 +35,8 @@ ReLU (Rectified Linear Unit)激活层 ...@@ -29,8 +35,8 @@ ReLU (Rectified Linear Unit)激活层
import paddle import paddle
import numpy as np import numpy as np
paddle.enable_imperative() paddle.disable_static()
lrelu = paddle.nn.LeakyReLU() m = paddle.nn.LeakyReLU()
x = paddle.imperative.to_variable(np.array([-2, 0, 1], 'float32')) x = paddle.to_tensor(np.array([-2, 0, 1], 'float32'))
out = lrelu(x) # [-0.02, 0, 1] out = m(x) # [-0.02, 0., 1.]
.. _cn_api_nn_ReLU6:
ReLU6
-------------------------------
.. py:class:: paddle.nn.ReLU6(name=None)
ReLU6激活层
.. math::
ReLU6(x) = min(max(0,x), 6)
其中,:math:`x` 为输入的 Tensor
参数
::::::::::
- name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。
形状:
::::::::::
- input: 任意形状的Tensor。
- output: 和input具有相同形状的Tensor。
代码示例
:::::::::
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
x = paddle.to_tensor(np.array([-1, 0.3, 6.5]))
m = paddle.nn.ReLU6()
out = m(x) # [0, 0.3, 6]
.. _cn_api_nn_SELU:
SELU
-------------------------------
.. py:class:: paddle.nn.SELU(scale=1.0507009873554804934193349852946, alpha=1.6732632423543772848170429916717, name=None)
SELU激活层
.. math::
SELU(x) = scale * (max(0,x) + min(0, alpha * (e^{x} - 1)))
其中,:math:`x` 为输入的 Tensor
参数
::::::::::
- scale (float, 可选) - SELU激活计算公式中的scale值。默认值为1.0507009873554804934193349852946。
- alpha (float, 可选) - SELU激活计算公式中的alpha值。默认值为1.6732632423543772848170429916717。
- name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。
形状:
::::::::::
- input: 任意形状的Tensor。
- output: 和input具有相同形状的Tensor。
代码示例
:::::::::
.. code-block:: python
import paddle
import numpy as np
paddle.disable_static()
x = paddle.to_tensor(np.array([[0.0, 1.0],[2.0, 3.0]]))
m = paddle.nn.SELU()
out = m(x) # [[0, 1.050701],[2.101402, 3.152103]]
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册