提交 30f297f6 编写于 作者: L Leo Chen 提交者: GitHub

Revert "update 1.8 apis, test=develop (#2052)"

This reverts commit 8ba38e07.
上级 8ba38e07
...@@ -7,7 +7,6 @@ fluid.dygraph ...@@ -7,7 +7,6 @@ fluid.dygraph
dygraph/BackwardStrategy.rst dygraph/BackwardStrategy.rst
dygraph/BatchNorm.rst dygraph/BatchNorm.rst
dygraph/BCELoss.rst
dygraph/BilinearTensorProduct.rst dygraph/BilinearTensorProduct.rst
dygraph/Conv2D.rst dygraph/Conv2D.rst
dygraph/Conv2DTranspose.rst dygraph/Conv2DTranspose.rst
...@@ -28,22 +27,17 @@ fluid.dygraph ...@@ -28,22 +27,17 @@ fluid.dygraph
dygraph/ExponentialDecay.rst dygraph/ExponentialDecay.rst
dygraph/grad.rst dygraph/grad.rst
dygraph/GroupNorm.rst dygraph/GroupNorm.rst
dygraph/GRUCell.rst
dygraph/GRUUnit.rst dygraph/GRUUnit.rst
dygraph/guard.rst dygraph/guard.rst
dygraph/InstanceNorm.rst dygraph/InstanceNorm.rst
dygraph/InverseTimeDecay.rst dygraph/InverseTimeDecay.rst
dygraph/L1Loss.rst
dygraph/Layer.rst dygraph/Layer.rst
dygraph/LayerList.rst dygraph/LayerList.rst
dygraph/LayerNorm.rst dygraph/LayerNorm.rst
dygraph/Linear.rst dygraph/Linear.rst
dygraph/load_dygraph.rst dygraph/load_dygraph.rst
dygraph/LSTMCell.rst
dygraph/MSELoss.rst
dygraph/NaturalExpDecay.rst dygraph/NaturalExpDecay.rst
dygraph/NCE.rst dygraph/NCE.rst
dygraph/NLLLoss.rst
dygraph/no_grad.rst dygraph/no_grad.rst
dygraph/NoamDecay.rst dygraph/NoamDecay.rst
dygraph/ParallelEnv.rst dygraph/ParallelEnv.rst
......
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_BCELoss:
BCELoss
-------
.. autoclass:: paddle.fluid.dygraph.BCELoss
:members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_InstanceNorm:
InstanceNorm
------------
.. autoclass:: paddle.fluid.dygraph.InstanceNorm
:members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_MSELoss:
MSELoss
-------
.. autoclass:: paddle.fluid.dygraph.MSELoss
:members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_NLLLoss:
NLLLoss
-------
.. autoclass:: paddle.fluid.dygraph.NLLLoss
:members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_ProgramTranslator:
ProgramTranslator
-----------------
.. autoclass:: paddle.fluid.dygraph.ProgramTranslator
:members:
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_dygraph_declarative:
declarative
-----------
.. autofunction:: paddle.fluid.dygraph.declarative
:noindex:
...@@ -10,6 +10,33 @@ done ...@@ -10,6 +10,33 @@ done
python gen_doc.py --module_name "" --module_prefix "" --output fluid --output_name fluid --to_multiple_files True python gen_doc.py --module_name "" --module_prefix "" --output fluid --output_name fluid --to_multiple_files True
python gen_module_index.py fluid fluid python gen_module_index.py fluid fluid
# tensor
for module in math random stat
do
python gen_doc.py --module_name ${module} --module_prefix ${module} --output ${module} --output_name tensor --to_multiple_files True --output_dir tensor
python gen_module_index.py tensor.${module} ${module}
done
python gen_module_index.py tensor paddle.tensor
for module in math manipulation
do
python gen_doc.py --module_name tensor.${module} --module_prefix tensor.${module} --output tensor/${module} --output_name complex --to_multiple_files True --output_dir complex
python gen_module_index.py complex.tensor.${module} ${module}
done
python gen_module_index.py complex.tensor tensor
python gen_module_index.py complex paddle.complex
# nn
for module in loss
do
python gen_doc.py --module_name ${module} --module_prefix ${module} --output ${module} --output_name nn --to_multiple_files True --output_dir nn
python gen_module_index.py nn.${module} ${module}
done
python gen_doc.py --module_name "" --module_prefix "" --output nn --output_name nn --to_multiple_files True
python gen_module_index.py nn paddle.nn
# index.rst # index.rst
python gen_index.py python gen_index.py
......
...@@ -6,6 +6,9 @@ API Reference ...@@ -6,6 +6,9 @@ API Reference
:maxdepth: 1 :maxdepth: 1
../api_guides/index_en.rst ../api_guides/index_en.rst
complex.rst
nn.rst
tensor.rst
fluid.rst fluid.rst
backward.rst backward.rst
clip.rst clip.rst
...@@ -14,6 +17,7 @@ API Reference ...@@ -14,6 +17,7 @@ API Reference
dataset.rst dataset.rst
dygraph.rst dygraph.rst
executor.rst executor.rst
index.rst
initializer.rst initializer.rst
io.rst io.rst
layers.rst layers.rst
......
...@@ -11,13 +11,9 @@ fluid.layers ...@@ -11,13 +11,9 @@ fluid.layers
layers/adaptive_pool2d.rst layers/adaptive_pool2d.rst
layers/adaptive_pool3d.rst layers/adaptive_pool3d.rst
layers/add_position_encoding.rst layers/add_position_encoding.rst
layers/addcmul.rst
layers/addmm.rst
layers/affine_channel.rst layers/affine_channel.rst
layers/affine_grid.rst layers/affine_grid.rst
layers/allclose.rst
layers/anchor_generator.rst layers/anchor_generator.rst
layers/arange.rst
layers/argmax.rst layers/argmax.rst
layers/argmin.rst layers/argmin.rst
layers/argsort.rst layers/argsort.rst
...@@ -36,7 +32,6 @@ fluid.layers ...@@ -36,7 +32,6 @@ fluid.layers
layers/BeamSearchDecoder.rst layers/BeamSearchDecoder.rst
layers/bilinear_tensor_product.rst layers/bilinear_tensor_product.rst
layers/bipartite_match.rst layers/bipartite_match.rst
layers/bmm.rst
layers/box_clip.rst layers/box_clip.rst
layers/box_coder.rst layers/box_coder.rst
layers/box_decoder_and_assign.rst layers/box_decoder_and_assign.rst
...@@ -48,7 +43,6 @@ fluid.layers ...@@ -48,7 +43,6 @@ fluid.layers
layers/ceil.rst layers/ceil.rst
layers/center_loss.rst layers/center_loss.rst
layers/chunk_eval.rst layers/chunk_eval.rst
layers/clamp.rst
layers/clip.rst layers/clip.rst
layers/clip_by_norm.rst layers/clip_by_norm.rst
layers/collect_fpn_proposals.rst layers/collect_fpn_proposals.rst
...@@ -70,7 +64,6 @@ fluid.layers ...@@ -70,7 +64,6 @@ fluid.layers
layers/crf_decoding.rst layers/crf_decoding.rst
layers/crop.rst layers/crop.rst
layers/crop_tensor.rst layers/crop_tensor.rst
layers/cross.rst
layers/cross_entropy.rst layers/cross_entropy.rst
layers/ctc_greedy_decoder.rst layers/ctc_greedy_decoder.rst
layers/cumsum.rst layers/cumsum.rst
...@@ -83,11 +76,8 @@ fluid.layers ...@@ -83,11 +76,8 @@ fluid.layers
layers/density_prior_box.rst layers/density_prior_box.rst
layers/detection_output.rst layers/detection_output.rst
layers/diag.rst layers/diag.rst
layers/diag_embed.rst
layers/dice_loss.rst layers/dice_loss.rst
layers/dist.rst
layers/distribute_fpn_proposals.rst layers/distribute_fpn_proposals.rst
layers/dot.rst
layers/double_buffer.rst layers/double_buffer.rst
layers/dropout.rst layers/dropout.rst
layers/dynamic_decode.rst layers/dynamic_decode.rst
...@@ -98,7 +88,6 @@ fluid.layers ...@@ -98,7 +88,6 @@ fluid.layers
layers/edit_distance.rst layers/edit_distance.rst
layers/elementwise_add.rst layers/elementwise_add.rst
layers/elementwise_div.rst layers/elementwise_div.rst
layers/elementwise_equal.rst
layers/elementwise_floordiv.rst layers/elementwise_floordiv.rst
layers/elementwise_max.rst layers/elementwise_max.rst
layers/elementwise_min.rst layers/elementwise_min.rst
...@@ -120,11 +109,8 @@ fluid.layers ...@@ -120,11 +109,8 @@ fluid.layers
layers/fill_constant_batch_size_like.rst layers/fill_constant_batch_size_like.rst
layers/filter_by_instag.rst layers/filter_by_instag.rst
layers/flatten.rst layers/flatten.rst
layers/flip.rst
layers/floor.rst layers/floor.rst
layers/fsp_matrix.rst layers/fsp_matrix.rst
layers/full.rst
layers/full_like.rst
layers/gather.rst layers/gather.rst
layers/gather_nd.rst layers/gather_nd.rst
layers/gather_tree.rst layers/gather_tree.rst
...@@ -155,16 +141,13 @@ fluid.layers ...@@ -155,16 +141,13 @@ fluid.layers
layers/image_resize.rst layers/image_resize.rst
layers/image_resize_short.rst layers/image_resize_short.rst
layers/increment.rst layers/increment.rst
layers/index_select.rst
layers/inplace_abn.rst layers/inplace_abn.rst
layers/instance_norm.rst layers/instance_norm.rst
layers/interpolate.rst
layers/inverse_time_decay.rst layers/inverse_time_decay.rst
layers/iou_similarity.rst layers/iou_similarity.rst
layers/is_empty.rst layers/is_empty.rst
layers/isfinite.rst layers/isfinite.rst
layers/kldiv_loss.rst layers/kldiv_loss.rst
layers/kron.rst
layers/l2_normalize.rst layers/l2_normalize.rst
layers/label_smooth.rst layers/label_smooth.rst
layers/layer_norm.rst layers/layer_norm.rst
...@@ -179,15 +162,12 @@ fluid.layers ...@@ -179,15 +162,12 @@ fluid.layers
layers/lod_append.rst layers/lod_append.rst
layers/lod_reset.rst layers/lod_reset.rst
layers/log.rst layers/log.rst
layers/log1p.rst
layers/log_loss.rst layers/log_loss.rst
layers/log_softmax.rst
layers/logical_and.rst layers/logical_and.rst
layers/logical_not.rst layers/logical_not.rst
layers/logical_or.rst layers/logical_or.rst
layers/logical_xor.rst layers/logical_xor.rst
layers/logsigmoid.rst layers/logsigmoid.rst
layers/logsumexp.rst
layers/lrn.rst layers/lrn.rst
layers/lstm.rst layers/lstm.rst
layers/lstm_unit.rst layers/lstm_unit.rst
...@@ -198,7 +178,6 @@ fluid.layers ...@@ -198,7 +178,6 @@ fluid.layers
layers/mean.rst layers/mean.rst
layers/mean_iou.rst layers/mean_iou.rst
layers/merge_selected_rows.rst layers/merge_selected_rows.rst
layers/meshgrid.rst
layers/mse_loss.rst layers/mse_loss.rst
layers/mul.rst layers/mul.rst
layers/multi_box_head.rst layers/multi_box_head.rst
...@@ -208,7 +187,6 @@ fluid.layers ...@@ -208,7 +187,6 @@ fluid.layers
layers/natural_exp_decay.rst layers/natural_exp_decay.rst
layers/nce.rst layers/nce.rst
layers/noam_decay.rst layers/noam_decay.rst
layers/nonzero.rst
layers/Normal.rst layers/Normal.rst
layers/not_equal.rst layers/not_equal.rst
layers/npair_loss.rst layers/npair_loss.rst
...@@ -232,10 +210,7 @@ fluid.layers ...@@ -232,10 +210,7 @@ fluid.layers
layers/psroi_pool.rst layers/psroi_pool.rst
layers/py_func.rst layers/py_func.rst
layers/py_reader.rst layers/py_reader.rst
layers/randint.rst
layers/randn.rst
layers/random_crop.rst layers/random_crop.rst
layers/randperm.rst
layers/range.rst layers/range.rst
layers/rank.rst layers/rank.rst
layers/rank_loss.rst layers/rank_loss.rst
...@@ -263,7 +238,6 @@ fluid.layers ...@@ -263,7 +238,6 @@ fluid.layers
layers/roi_align.rst layers/roi_align.rst
layers/roi_perspective_transform.rst layers/roi_perspective_transform.rst
layers/roi_pool.rst layers/roi_pool.rst
layers/roll.rst
layers/round.rst layers/round.rst
layers/row_conv.rst layers/row_conv.rst
layers/rpn_target_assign.rst layers/rpn_target_assign.rst
...@@ -327,7 +301,6 @@ fluid.layers ...@@ -327,7 +301,6 @@ fluid.layers
layers/swish.rst layers/swish.rst
layers/Switch.rst layers/Switch.rst
layers/switch_case.rst layers/switch_case.rst
layers/t.rst
layers/tanh.rst layers/tanh.rst
layers/tanh_shrink.rst layers/tanh_shrink.rst
layers/target_assign.rst layers/target_assign.rst
...@@ -336,11 +309,8 @@ fluid.layers ...@@ -336,11 +309,8 @@ fluid.layers
layers/tensor_array_to_tensor.rst layers/tensor_array_to_tensor.rst
layers/thresholded_relu.rst layers/thresholded_relu.rst
layers/topk.rst layers/topk.rst
layers/trace.rst
layers/TrainingHelper.rst layers/TrainingHelper.rst
layers/transpose.rst layers/transpose.rst
layers/tril.rst
layers/triu.rst
layers/unfold.rst layers/unfold.rst
layers/Uniform.rst layers/Uniform.rst
layers/uniform_random.rst layers/uniform_random.rst
......
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_addcmul:
addcmul
-------
.. autofunction:: paddle.fluid.layers.addcmul
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_addmm:
addmm
-----
.. autofunction:: paddle.fluid.layers.addmm
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_allclose:
allclose
--------
.. autofunction:: paddle.fluid.layers.allclose
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_arange:
arange
------
.. autofunction:: paddle.fluid.layers.arange
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_clamp:
clamp
-----
.. autofunction:: paddle.fluid.layers.clamp
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_cross:
cross
-----
.. autofunction:: paddle.fluid.layers.cross
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_diag_embed:
diag_embed
----------
.. autofunction:: paddle.fluid.layers.diag_embed
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_elementwise_equal:
elementwise_equal
-----------------
.. autofunction:: paddle.fluid.layers.elementwise_equal
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_full_like:
full_like
---------
.. autofunction:: paddle.fluid.layers.full_like
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_index_select:
index_select
------------
.. autofunction:: paddle.fluid.layers.index_select
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_interpolate:
interpolate
-----------
.. autofunction:: paddle.fluid.layers.interpolate
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_log1p:
log1p
-----
.. autofunction:: paddle.fluid.layers.log1p
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_log_softmax:
log_softmax
-----------
.. autofunction:: paddle.fluid.layers.log_softmax
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_logsumexp:
logsumexp
---------
.. autofunction:: paddle.fluid.layers.logsumexp
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_nonzero:
nonzero
-------
.. autofunction:: paddle.fluid.layers.nonzero
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_randn:
randn
-----
.. autofunction:: paddle.fluid.layers.randn
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_roll:
roll
----
.. autofunction:: paddle.fluid.layers.roll
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_trace:
trace
-----
.. autofunction:: paddle.fluid.layers.trace
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_tril:
tril
----
.. autofunction:: paddle.fluid.layers.tril
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_fluid_layers_triu:
triu
----
.. autofunction:: paddle.fluid.layers.triu
:noindex:
=========
paddle.nn
=========
.. toctree::
:maxdepth: 1
nn/loss.rst
====
loss
====
.. toctree::
:maxdepth: 1
loss/BCELoss.rst
loss/CrossEntropyLoss.rst
loss/L1Loss.rst
loss/MSELoss.rst
loss/NLLLoss.rst
.. 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_L1Loss: .. _api_nn_loss_L1Loss:
L1Loss L1Loss
------ ------
.. autoclass:: paddle.fluid.dygraph.L1Loss .. autoclass:: paddle.nn.loss.L1Loss
:members: :members:
:inherited-members:
:noindex: :noindex:
=============
paddle.tensor
=============
.. toctree::
:maxdepth: 1
tensor/linalg.rst
tensor/math.rst
tensor/random.rst
tensor/stat.rst
======
linalg
======
.. toctree::
:maxdepth: 1
linalg/dist.rst
.. 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_layers_meshgrid: .. _api_tensor_linalg_dist:
meshgrid dist
-------- --------
.. autofunction:: paddle.fluid.layers.meshgrid .. autofunction:: paddle.tensor.linalg.dist
:noindex: :noindex:
====
math
====
.. toctree::
:maxdepth: 1
math/add.rst
math/addcmul.rst
math/addmm.rst
math/atan.rst
math/clamp.rst
math/div.rst
math/elementwise_sum.rst
math/log1p.rst
math/logsumexp.rst
math/max.rst
math/min.rst
math/mm.rst
math/mul.rst
math/pow.rst
math/sin.rst
math/sqrt.rst
math/sum.rst
math/tanh.rst
.. 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_layers_dot: .. _api_tensor_math_add:
dot add
--- ---
.. autofunction:: paddle.fluid.layers.dot .. autofunction:: paddle.tensor.math.add
:noindex: :noindex:
.. 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_layers_dist: .. _api_tensor_math_atan:
dist atan
---- ----
.. autofunction:: paddle.fluid.layers.dist .. autofunction:: paddle.tensor.math.atan
:noindex: :noindex:
.. 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_layers_bmm: .. _api_tensor_math_div:
bmm div
--- ---
.. autofunction:: paddle.fluid.layers.bmm .. autofunction:: paddle.tensor.math.div
:noindex: :noindex:
.. 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_ComplexVariable: .. _api_tensor_math_elementwise_sum:
ComplexVariable elementwise_sum
--------------- ---------------
.. autoclass:: paddle.fluid.ComplexVariable .. autofunction:: paddle.tensor.math.elementwise_sum
:members:
:inherited-members:
:noindex: :noindex:
.. 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_layers_t: .. _api_tensor_math_mm:
t mm
- --
.. autofunction:: paddle.fluid.layers.t .. autofunction:: paddle.tensor.math.mm
:noindex: :noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_mul:
mul
---
.. autofunction:: paddle.tensor.math.mul
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_pow:
pow
---
.. autofunction:: paddle.tensor.math.pow
:noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_sin:
sin
---
.. autofunction:: paddle.tensor.math.sin
:noindex:
.. 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_layers_full: .. _api_tensor_math_sqrt:
full sqrt
---- ----
.. autofunction:: paddle.fluid.layers.full .. autofunction:: paddle.tensor.math.sqrt
:noindex: :noindex:
.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}`
!DO NOT EDIT THIS FILE MANUALLY!
.. _api_tensor_math_sum:
sum
---
.. autofunction:: paddle.tensor.math.sum
:noindex:
.. 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_layers_flip: .. _api_tensor_math_tanh:
flip tanh
---- ----
.. autofunction:: paddle.fluid.layers.flip .. autofunction:: paddle.tensor.math.tanh
:noindex: :noindex:
======
random
======
.. toctree::
:maxdepth: 1
random/randint.rst
random/randn.rst
random/randperm.rst
.. 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_layers_kron: .. _api_tensor_random_rand:
kron rand
---- ----
.. autofunction:: paddle.fluid.layers.kron .. autofunction:: paddle.tensor.random.rand
:noindex: :noindex:
.. 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_layers_randint: .. _api_tensor_random_randint:
randint randint
------- -------
.. autofunction:: paddle.fluid.layers.randint .. autofunction:: paddle.tensor.random.randint
:noindex: :noindex:
.. 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_layers_randperm: .. _api_tensor_random_randperm:
randperm randperm
-------- --------
.. autofunction:: paddle.fluid.layers.randperm .. autofunction:: paddle.tensor.random.randperm
:noindex: :noindex:
...@@ -10,7 +10,6 @@ fluid.dygraph ...@@ -10,7 +10,6 @@ fluid.dygraph
dygraph_cn/BackwardStrategy_cn.rst dygraph_cn/BackwardStrategy_cn.rst
dygraph_cn/BatchNorm_cn.rst dygraph_cn/BatchNorm_cn.rst
dygraph_cn/BCELoss_cn.rst
dygraph_cn/BilinearTensorProduct_cn.rst dygraph_cn/BilinearTensorProduct_cn.rst
dygraph_cn/Conv2D_cn.rst dygraph_cn/Conv2D_cn.rst
dygraph_cn/Conv2DTranspose_cn.rst dygraph_cn/Conv2DTranspose_cn.rst
...@@ -18,7 +17,6 @@ fluid.dygraph ...@@ -18,7 +17,6 @@ fluid.dygraph
dygraph_cn/Conv3DTranspose_cn.rst dygraph_cn/Conv3DTranspose_cn.rst
dygraph_cn/CosineDecay_cn.rst dygraph_cn/CosineDecay_cn.rst
dygraph_cn/Dropout_cn.rst dygraph_cn/Dropout_cn.rst
dygraph_cn/declarative_cn.rst
dygraph_cn/Embedding_cn.rst dygraph_cn/Embedding_cn.rst
dygraph_cn/ExponentialDecay_cn.rst dygraph_cn/ExponentialDecay_cn.rst
dygraph_cn/FC_cn.rst dygraph_cn/FC_cn.rst
...@@ -26,18 +24,14 @@ fluid.dygraph ...@@ -26,18 +24,14 @@ fluid.dygraph
dygraph_cn/GroupNorm_cn.rst dygraph_cn/GroupNorm_cn.rst
dygraph_cn/GRUUnit_cn.rst dygraph_cn/GRUUnit_cn.rst
dygraph_cn/guard_cn.rst dygraph_cn/guard_cn.rst
dygraph_cn/InstanceNorm_cn.rst
dygraph_cn/InverseTimeDecay_cn.rst dygraph_cn/InverseTimeDecay_cn.rst
dygraph_cn/L1Loss_cn.rst
dygraph_cn/Layer_cn.rst dygraph_cn/Layer_cn.rst
dygraph_cn/LayerList_cn.rst dygraph_cn/LayerList_cn.rst
dygraph_cn/LayerNorm_cn.rst dygraph_cn/LayerNorm_cn.rst
dygraph_cn/Linear_cn.rst dygraph_cn/Linear_cn.rst
dygraph_cn/load_dygraph_cn.rst dygraph_cn/load_dygraph_cn.rst
dygraph_cn/MSELoss_cn.rst
dygraph_cn/NaturalExpDecay_cn.rst dygraph_cn/NaturalExpDecay_cn.rst
dygraph_cn/NCE_cn.rst dygraph_cn/NCE_cn.rst
dygraph_cn/NLLLoss_cn.rst
dygraph_cn/NoamDecay_cn.rst dygraph_cn/NoamDecay_cn.rst
dygraph_cn/ParallelEnv_cn.rst dygraph_cn/ParallelEnv_cn.rst
dygraph_cn/ParameterList_cn.rst dygraph_cn/ParameterList_cn.rst
...@@ -47,7 +41,6 @@ fluid.dygraph ...@@ -47,7 +41,6 @@ fluid.dygraph
dygraph_cn/Pool2D_cn.rst dygraph_cn/Pool2D_cn.rst
dygraph_cn/PRelu_cn.rst dygraph_cn/PRelu_cn.rst
dygraph_cn/prepare_context_cn.rst dygraph_cn/prepare_context_cn.rst
dygraph_cn/ProgramTranslator_cn.rst
dygraph_cn/save_dygraph_cn.rst dygraph_cn/save_dygraph_cn.rst
dygraph_cn/Sequential_cn.rst dygraph_cn/Sequential_cn.rst
dygraph_cn/SpectralNorm_cn.rst dygraph_cn/SpectralNorm_cn.rst
......
L1Loss
-------------------------------
.. py:function:: paddle.fluid.layers.L1Loss(reduction='mean')
该接口用于创建一个L1Loss的可调用类,L1Loss计算输入input和标签label间的 `L1 loss` 损失。
该损失函数的数学计算公式如下:
当 `reduction` 设置为 ``'none'`` 时,
.. math::
Out = |input - label|
当 `reduction` 设置为 ``'mean'`` 时,
.. math::
Out = MEAN(|input - label|)
当 `reduction` 设置为 ``'sum'`` 时,
.. math::
Out = SUM(|input - label|)
输入input和标签label的维度是[N, *], 其中N是batch_size, `*` 是任意其他维度。
如果 :attr:`reduction` 是 ``'none'``, 则输出Loss的维度为 [N, *], 与输入input相同。
如果 :attr:`reduction` 是 ``'mean'`` 或 ``'sum'``, 则输出Loss的维度为 [1]。
参数:
- **reduction** (string, 可选): - 指定应用于输出结果的计算方式,可选值有: ``'none'``, ``'mean'``, ``'sum'`` 。默认为 ``'mean'``,计算 `L1Loss` 的均值;设置为 ``'sum'`` 时,计算 `L1Loss` 的总和;设置为 ``'none'`` 时,则返回L1Loss。数据类型为string。
返回:返回计算L1Loss的可调用对象。
**代码示例**
.. code-block:: python
# declarative mode
import paddle.fluid as fluid
import numpy as np
import paddle
input = fluid.data(name="input", shape=[1])
label = fluid.data(name="label", shape=[1])
l1_loss = fluid.layers.L1Loss(reduction='mean')
output = l1_loss(input,label)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
input_data = np.array([1.5]).astype("float32")
label_data = np.array([1.7]).astype("float32")
output_data = exe.run(fluid.default_main_program(),
feed={"input":input_data, "label":label_data},
fetch_list=[output],
return_numpy=True)
print(output_data) # [array([0.2], dtype=float32)]
# imperative mode
import paddle.fluid.dygraph as dg
with dg.guard(place) as g:
input = dg.to_variable(input_data)
label = dg.to_variable(label_data)
l1_loss = fluid.layers.L1Loss(reduction='mean')
output = l1_loss(input,label)
print(output.numpy()) # [0.2]
NLLLoss NLLLoss
------------------------------- -------------------------------
**版本升级,文档正在开发中**
.. py:function:: paddle.fluid.dygraph.NLLLoss(weight=None, reduction='mean', ignore_index=-100)
该OP计算输入input和标签label间的 `negative log likelihood loss` 损失 ,可用于训练一个 `n` 类分类器。
如果提供 `weight` 参数的话,它是一个 `1-D` 的tensor, 里面的值对应类别的权重。当你的训练集样本
不均衡的话,使用这个参数是非常有用的。
该损失函数的数学计算公式如下:
当 `reduction` 设置为 `none` 时,损失函数的数学计算公式为:
.. math::
\ell(x, y) = L = \{l_1,\dots,l_N\}^\top, \quad
l_n = - w_{y_n} x_{n,y_n}, \quad
w_{c} = \text{weight}[c] \cdot \mathbb{1}\{c \not= \text{ignore_index}\},
其中 `N` 表示 `batch_size` 。如果 `reduction` 的值不是 `none` (默认为 `mean`),那么此时损失函数
的数学计算公式为:
.. math::
\ell(x, y) = \begin{cases}
\sum_{n=1}^N \frac{1}{\sum_{n=1}^N w_{y_n}} l_n, &
\text{if reduction} = \text{'mean';}\\
\sum_{n=1}^N l_n, &
\text{if reduction} = \text{'sum'.}
\end{cases}
参数:
- **input** (Variable): - 输入 `Tensor`, 其形状为 :math:`[N, C]` , 其中 `C` 为类别数。但是对于多维度的情形下,它的形状为 :math:`[N, C, d_1, d_2, ..., d_K]` 。数据类型为float32或float64。
- **label** (Variable): - 输入input对应的标签值。其形状为 :math:`[N,]` 或者 :math:`[N, d_1, d_2, ..., d_K]`, 数据类型为int64。
- **weight** (Variable, 可选): - 手动指定每个类别的权重。其默认为 `None` 。如果提供该参数的话,长度必须为 `num_classes` 。数据类型为float32或float64。
- **reduction** (string, 可选): - 指定应用于输出结果的计算方式,可选值有: `none`, `mean`, `sum` 。默认为 `mean` ,计算 `mini-batch` loss均值。设置为 `sum` 时,计算 `mini-batch` loss的总和。设置为 `none` 时,则返回loss Tensor。数据类型为string。
- **ignore_index** (int64, 可选): - 指定一个忽略的标签值,此标签值不参与计算。默认值为-100。数据类型为int64。
返回:返回存储表示 `negative log likihood loss` 的损失值。
返回类型:Variable
**代码示例**
.. code-block:: python
# declarative mode
import paddle.fluid as fluid
import numpy as np
import paddle
input_np = np.random.random(size=(10, 10)).astype(np.float32)
label_np = np.random.randint(0, 10, size=(10,)).astype(np.int64)
prog = fluid.Program()
startup_prog = fluid.Program()
place = fluid.CPUPlace()
with fluid.program_guard(prog, startup_prog):
input = fluid.data(name='input', shape=[10, 10], dtype='float32')
label = fluid.data(name='label', shape=[10], dtype='int64')
nll_loss = fluid.dygraph.NLLLoss()
res = nll_loss(input, label)
exe = fluid.Executor(place)
static_result = exe.run(
prog,
feed={"input": input_np,
"label": label_np},
fetch_list=[res])
print(static_result)
# imperative mode
import paddle.fluid.dygraph as dg
with dg.guard(place) as g:
input = dg.to_variable(input_np)
label = dg.to_variable(label_np)
output = nll_loss(input, label)
print(output.numpy())
ProgramTranslator
-------------------------------
**版本升级,文档正在开发中**
declarative
-------------------------------
**版本升级,文档正在开发中**
=======================
paddle.framework
=======================
.. toctree::
:maxdepth: 1
framework_cn/get_default_dtype_cn.rst
framework_cn/manual_seed_cn.rst
framework_cn/set_default_dtype_cn.rst
get
-------------------------------
**版本升级,文档正在开发中**
manual
-------------------------------
**版本升级,文档正在开发中**
set
-------------------------------
**版本升级,文档正在开发中**
...@@ -6,6 +6,9 @@ API Reference ...@@ -6,6 +6,9 @@ API Reference
:maxdepth: 1 :maxdepth: 1
../api_guides/index_cn.rst ../api_guides/index_cn.rst
framework_cn.rst
nn_cn.rst
tensor_cn.rst
fluid_cn.rst fluid_cn.rst
api_tree_cn.rst api_tree_cn.rst
backward_cn.rst backward_cn.rst
...@@ -21,5 +24,6 @@ API Reference ...@@ -21,5 +24,6 @@ API Reference
optimizer_cn.rst optimizer_cn.rst
profiler_cn.rst profiler_cn.rst
regularizer_cn.rst regularizer_cn.rst
tensor_cn.rst
transpiler_cn.rst transpiler_cn.rst
unique_name_cn.rst unique_name_cn.rst
...@@ -16,13 +16,9 @@ fluid.layers ...@@ -16,13 +16,9 @@ fluid.layers
layers_cn/adaptive_pool2d_cn.rst layers_cn/adaptive_pool2d_cn.rst
layers_cn/adaptive_pool3d_cn.rst layers_cn/adaptive_pool3d_cn.rst
layers_cn/add_position_encoding_cn.rst layers_cn/add_position_encoding_cn.rst
layers_cn/addcmul_cn.rst
layers_cn/addmm_cn.rst
layers_cn/affine_channel_cn.rst layers_cn/affine_channel_cn.rst
layers_cn/affine_grid_cn.rst layers_cn/affine_grid_cn.rst
layers_cn/allclose_cn.rst
layers_cn/anchor_generator_cn.rst layers_cn/anchor_generator_cn.rst
layers_cn/arange_cn.rst
layers_cn/argmax_cn.rst layers_cn/argmax_cn.rst
layers_cn/argmin_cn.rst layers_cn/argmin_cn.rst
layers_cn/argsort_cn.rst layers_cn/argsort_cn.rst
...@@ -39,7 +35,6 @@ fluid.layers ...@@ -39,7 +35,6 @@ fluid.layers
layers_cn/beam_search_decode_cn.rst layers_cn/beam_search_decode_cn.rst
layers_cn/bilinear_tensor_product_cn.rst layers_cn/bilinear_tensor_product_cn.rst
layers_cn/bipartite_match_cn.rst layers_cn/bipartite_match_cn.rst
layers_cn/bmm_cn.rst
layers_cn/box_clip_cn.rst layers_cn/box_clip_cn.rst
layers_cn/box_coder_cn.rst layers_cn/box_coder_cn.rst
layers_cn/box_decoder_and_assign_cn.rst layers_cn/box_decoder_and_assign_cn.rst
...@@ -52,7 +47,6 @@ fluid.layers ...@@ -52,7 +47,6 @@ fluid.layers
layers_cn/ceil_cn.rst layers_cn/ceil_cn.rst
layers_cn/center_loss_cn.rst layers_cn/center_loss_cn.rst
layers_cn/chunk_eval_cn.rst layers_cn/chunk_eval_cn.rst
layers_cn/clamp_cn.rst
layers_cn/clip_by_norm_cn.rst layers_cn/clip_by_norm_cn.rst
layers_cn/clip_cn.rst layers_cn/clip_cn.rst
layers_cn/collect_fpn_proposals_cn.rst layers_cn/collect_fpn_proposals_cn.rst
...@@ -74,7 +68,6 @@ fluid.layers ...@@ -74,7 +68,6 @@ fluid.layers
layers_cn/crf_decoding_cn.rst layers_cn/crf_decoding_cn.rst
layers_cn/crop_cn.rst layers_cn/crop_cn.rst
layers_cn/crop_tensor_cn.rst layers_cn/crop_tensor_cn.rst
layers_cn/cross_cn.rst
layers_cn/cross_entropy_cn.rst layers_cn/cross_entropy_cn.rst
layers_cn/ctc_greedy_decoder_cn.rst layers_cn/ctc_greedy_decoder_cn.rst
layers_cn/cumsum_cn.rst layers_cn/cumsum_cn.rst
...@@ -85,11 +78,8 @@ fluid.layers ...@@ -85,11 +78,8 @@ fluid.layers
layers_cn/density_prior_box_cn.rst layers_cn/density_prior_box_cn.rst
layers_cn/detection_output_cn.rst layers_cn/detection_output_cn.rst
layers_cn/diag_cn.rst layers_cn/diag_cn.rst
layers_cn/diag_embed_cn.rst
layers_cn/dice_loss_cn.rst layers_cn/dice_loss_cn.rst
layers_cn/dist_cn.rst
layers_cn/distribute_fpn_proposals_cn.rst layers_cn/distribute_fpn_proposals_cn.rst
layers_cn/dot_cn.rst
layers_cn/double_buffer_cn.rst layers_cn/double_buffer_cn.rst
layers_cn/dropout_cn.rst layers_cn/dropout_cn.rst
layers_cn/dynamic_gru_cn.rst layers_cn/dynamic_gru_cn.rst
...@@ -101,7 +91,6 @@ fluid.layers ...@@ -101,7 +91,6 @@ fluid.layers
layers_cn/edit_distance_cn.rst layers_cn/edit_distance_cn.rst
layers_cn/elementwise_add_cn.rst layers_cn/elementwise_add_cn.rst
layers_cn/elementwise_div_cn.rst layers_cn/elementwise_div_cn.rst
layers_cn/elementwise_equal_cn.rst
layers_cn/elementwise_floordiv_cn.rst layers_cn/elementwise_floordiv_cn.rst
layers_cn/elementwise_max_cn.rst layers_cn/elementwise_max_cn.rst
layers_cn/elementwise_min_cn.rst layers_cn/elementwise_min_cn.rst
...@@ -122,11 +111,8 @@ fluid.layers ...@@ -122,11 +111,8 @@ fluid.layers
layers_cn/fill_constant_cn.rst layers_cn/fill_constant_cn.rst
layers_cn/filter_by_instag_cn.rst layers_cn/filter_by_instag_cn.rst
layers_cn/flatten_cn.rst layers_cn/flatten_cn.rst
layers_cn/flip_cn.rst
layers_cn/floor_cn.rst layers_cn/floor_cn.rst
layers_cn/fsp_matrix_cn.rst layers_cn/fsp_matrix_cn.rst
layers_cn/full_cn.rst
layers_cn/full_like_cn.rst
layers_cn/gather_cn.rst layers_cn/gather_cn.rst
layers_cn/gather_nd_cn.rst layers_cn/gather_nd_cn.rst
layers_cn/gather_tree_cn.rst layers_cn/gather_tree_cn.rst
...@@ -156,14 +142,11 @@ fluid.layers ...@@ -156,14 +142,11 @@ fluid.layers
layers_cn/image_resize_short_cn.rst layers_cn/image_resize_short_cn.rst
layers_cn/increment_cn.rst layers_cn/increment_cn.rst
layers_cn/inverse_time_decay_cn.rst layers_cn/inverse_time_decay_cn.rst
layers_cn/index_select_cn.rst
layers_cn/instance_norm_cn.rst layers_cn/instance_norm_cn.rst
layers_cn/interpolate_cn.rst
layers_cn/iou_similarity_cn.rst layers_cn/iou_similarity_cn.rst
layers_cn/is_empty_cn.rst layers_cn/is_empty_cn.rst
layers_cn/isfinite_cn.rst layers_cn/isfinite_cn.rst
layers_cn/kldiv_loss_cn.rst layers_cn/kldiv_loss_cn.rst
layers_cn/kron_cn.rst
layers_cn/l2_normalize_cn.rst layers_cn/l2_normalize_cn.rst
layers_cn/label_smooth_cn.rst layers_cn/label_smooth_cn.rst
layers_cn/layer_norm_cn.rst layers_cn/layer_norm_cn.rst
...@@ -177,15 +160,12 @@ fluid.layers ...@@ -177,15 +160,12 @@ fluid.layers
layers_cn/lod_append_cn.rst layers_cn/lod_append_cn.rst
layers_cn/lod_reset_cn.rst layers_cn/lod_reset_cn.rst
layers_cn/log_cn.rst layers_cn/log_cn.rst
layers_cn/log1p_cn.rst
layers_cn/log_loss_cn.rst layers_cn/log_loss_cn.rst
layers_cn/log_softmax_cn.rst
layers_cn/logical_and_cn.rst layers_cn/logical_and_cn.rst
layers_cn/logical_not_cn.rst layers_cn/logical_not_cn.rst
layers_cn/logical_or_cn.rst layers_cn/logical_or_cn.rst
layers_cn/logical_xor_cn.rst layers_cn/logical_xor_cn.rst
layers_cn/logsigmoid_cn.rst layers_cn/logsigmoid_cn.rst
layers_cn/logsumexp_cn.rst
layers_cn/lrn_cn.rst layers_cn/lrn_cn.rst
layers_cn/lstm_cn.rst layers_cn/lstm_cn.rst
layers_cn/lstm_unit_cn.rst layers_cn/lstm_unit_cn.rst
...@@ -197,7 +177,6 @@ fluid.layers ...@@ -197,7 +177,6 @@ fluid.layers
layers_cn/mean_cn.rst layers_cn/mean_cn.rst
layers_cn/mean_iou_cn.rst layers_cn/mean_iou_cn.rst
layers_cn/merge_selected_rows_cn.rst layers_cn/merge_selected_rows_cn.rst
layers_cn/meshgrid_cn.rst
layers_cn/mse_loss_cn.rst layers_cn/mse_loss_cn.rst
layers_cn/mul_cn.rst layers_cn/mul_cn.rst
layers_cn/multi_box_head_cn.rst layers_cn/multi_box_head_cn.rst
...@@ -207,7 +186,6 @@ fluid.layers ...@@ -207,7 +186,6 @@ fluid.layers
layers_cn/natural_exp_decay_cn.rst layers_cn/natural_exp_decay_cn.rst
layers_cn/nce_cn.rst layers_cn/nce_cn.rst
layers_cn/noam_decay_cn.rst layers_cn/noam_decay_cn.rst
layers_cn/nonzero_cn.rst
layers_cn/Normal_cn.rst layers_cn/Normal_cn.rst
layers_cn/not_equal_cn.rst layers_cn/not_equal_cn.rst
layers_cn/npair_loss_cn.rst layers_cn/npair_loss_cn.rst
...@@ -232,10 +210,8 @@ fluid.layers ...@@ -232,10 +210,8 @@ fluid.layers
layers_cn/py_func_cn.rst layers_cn/py_func_cn.rst
layers_cn/py_reader_cn.rst layers_cn/py_reader_cn.rst
layers_cn/randint_cn.rst layers_cn/randint_cn.rst
layers_cn/randn_cn.rst
layers_cn/random_crop_cn.rst layers_cn/random_crop_cn.rst
layers_cn/range_cn.rst layers_cn/range_cn.rst
layers_cn/randperm_cn.rst
layers_cn/rank_cn.rst layers_cn/rank_cn.rst
layers_cn/rank_loss_cn.rst layers_cn/rank_loss_cn.rst
layers_cn/read_file_cn.rst layers_cn/read_file_cn.rst
...@@ -261,7 +237,6 @@ fluid.layers ...@@ -261,7 +237,6 @@ fluid.layers
layers_cn/roi_align_cn.rst layers_cn/roi_align_cn.rst
layers_cn/roi_perspective_transform_cn.rst layers_cn/roi_perspective_transform_cn.rst
layers_cn/roi_pool_cn.rst layers_cn/roi_pool_cn.rst
layers_cn/roll_cn.rst
layers_cn/round_cn.rst layers_cn/round_cn.rst
layers_cn/row_conv_cn.rst layers_cn/row_conv_cn.rst
layers_cn/rpn_target_assign_cn.rst layers_cn/rpn_target_assign_cn.rst
...@@ -325,7 +300,6 @@ fluid.layers ...@@ -325,7 +300,6 @@ fluid.layers
layers_cn/swish_cn.rst layers_cn/swish_cn.rst
layers_cn/Switch_cn.rst layers_cn/Switch_cn.rst
layers_cn/switch_case_cn.rst layers_cn/switch_case_cn.rst
layers_cn/t_cn.rst
layers_cn/tanh_cn.rst layers_cn/tanh_cn.rst
layers_cn/tanh_shrink_cn.rst layers_cn/tanh_shrink_cn.rst
layers_cn/target_assign_cn.rst layers_cn/target_assign_cn.rst
...@@ -334,10 +308,7 @@ fluid.layers ...@@ -334,10 +308,7 @@ fluid.layers
layers_cn/tensor_array_to_tensor_cn.rst layers_cn/tensor_array_to_tensor_cn.rst
layers_cn/thresholded_relu_cn.rst layers_cn/thresholded_relu_cn.rst
layers_cn/topk_cn.rst layers_cn/topk_cn.rst
layers_cn/trace_cn.rst
layers_cn/transpose_cn.rst layers_cn/transpose_cn.rst
layers_cn/tril_cn.rst
layers_cn/triu_cn.rst
layers_cn/unfold_cn.rst layers_cn/unfold_cn.rst
layers_cn/Uniform_cn.rst layers_cn/Uniform_cn.rst
layers_cn/uniform_random_cn.rst layers_cn/uniform_random_cn.rst
......
.. _cn_api_fluid_layers_randint:
randint randint
------------------------------- -------------------------------
**版本升级,文档正在开发中**
.. py:function:: paddle.fluid.layers.randint(low, high=None, shape=None, out=None, dtype=None, device=None, stop_gradient=False, seed=0, name=None)
该OP使用从区间[low,high)内均匀分布采样的随机整数初始化一个Tensor。当high为None时(默认),均匀采样的区间为[0,low)。
参数:
- **low** (int)-要生成的随机值范围的下限,low包含在范围中。当high为None时,均匀采样的区间为[0,low)。
- **high** (int,可选)-要生成的随机值范围的上限,high不包含在范围中。默认值为None。
- **shape** (list|tuple|Variable,可选)-输出Tensor的维度,shape类型支持list,tuple,Variable。如果shape类型是list或者tuple,它的元素可以是整数或者形状为[1]的Tensor,其中整数的数据类型为int,Tensor的数据类型为int32或int64。如果shape的类型是Variable,则是1D的Tensor,Tensor的数据类型为int32或int64。如果shape为None,则会将shape设置为[1]。默认值为None。
- **out** (Variable,可选)-用于存储创建的Tensor,可以是程序中已经创建的任何Variable。默认值为None,此时将创建新的Variable来保存输出结果。
- **dtype** (np.dtype|core.VarDesc.VarType|str,可选)- 输出Tensor的数据类型,支持数据类型为int32,int64。如果dtype为None,则会将dtype设置为int64。默认值为None。
- **device** (str, 可选)-指定在GPU或CPU上创建Tensor。如果device为None,则将选择运行Paddle程序的设备,默认为None。
- **stop_gradient** (bool,可选)-指定是否停止梯度计算,默认值为False。
- **seed** (int,可选)-随机种子,用于生成样本。0表示使用系统生成的种子。注意如果种子不为0,该操作符每次都生成同样的随机数。默认为 0。
- **name** (str,可选)-具体用法请参见:ref:`api_guide_Name` ,一般无需设置,默认值为None。
返回:表示一个随机初始化结果的Tensor,该Tensor的数据类型由dtype参数决定,该Tensor的维度由shape参数决定。
返回类型:Variable
抛出异常:
- :code:`TypeError`: shape的类型应该是list、tuple 或 Variable。
- :code:`TypeError`: dtype的类型应该是int32或int64。
- :code:`ValueError`: 该OP的high必须大于low(high为None时,则会先将high设置为low,将low设置为0,再判断low和high的大小关系)。
**代码示例**:
.. code-block:: python
import paddle.fluid as fluid
# example 1:
# attr shape is a list which doesn't contain tensor Variable.
result_1 = fluid.layers.randint(low=-5, high=5, shape=[3, 4], dtype="int64")
# example 2:
# attr shape is a list which contains tensor Variable.
dim_1 = fluid.layers.fill_constant([1],"int64",3)
dim_2 = fluid.layers.fill_constant([1],"int32",5)
result_2 = fluid.layers.randint(low=-5, high=5, shape=[dim_1, dim_2], dtype="int32")
# example 3:
# attr shape is a Variable, the data type must be int64 or int32.
var_shape = fluid.data(name='var_shape', shape=[2], dtype="int64")
result_3 = fluid.layers.randint(low=-5, high=5, shape=var_shape, dtype="int32")
var_shape_int32 = fluid.data(name='var_shape_int32', shape=[2], dtype="int32")
result_4 = fluid.layers.randint(low=-5, high=5, shape=var_shape_int32, dtype="int64")
# example 4:
# Input only one parameter
# low=0, high=10, shape=[1], dtype='int64'
result_4 = fluid.layers.randint(10)
trace
-------------------------------
**版本升级,文档正在开发中**
=======================
paddle.nn
=======================
.. toctree::
:maxdepth: 1
nn_cn/Conv1D_cn.rst
nn_cn/Conv2D_cn.rst
nn_cn/diag_embed_cn.rst
nn_cn/interpolate_cn.rst
nn_cn/Linear_cn.rst
nn_cn/log_softmax_cn.rst
nn_cn/ReLU_cn.rst
nn_cn/Upsample_cn.rst
nn_cn/activation_cn.rst
nn_cn/loss_cn.rst
Conv1D
-------------------------------
**版本升级,文档正在开发中**
Conv2D
-------------------------------
**版本升级,文档正在开发中**
Linear
-------------------------------
**版本升级,文档正在开发中**
ReLU
-------------------------------
**版本升级,文档正在开发中**
Upsample
-------------------------------
**版本升级,文档正在开发中**
=======================
activation
=======================
.. toctree::
:maxdepth: 1
activation_cn/Sigmoid_cn.rst
Sigmoid
-------------------------------
**版本升级,文档正在开发中**
=======================
loss
=======================
.. toctree::
:maxdepth: 1
loss_cn/BCELoss_cn.rst
loss_cn/CrossEntropyLoss_cn.rst
loss_cn/L1Loss_cn.rst
loss_cn/MSELoss_cn.rst
loss_cn/NLLLoss_cn.rst
InstanceNorm CrossEntropyLoss
------------------------------- -------------------------------
**版本升级,文档正在开发中** **版本升级,文档正在开发中**
L1Loss
-------------------------------
**版本升级,文档正在开发中**
NLLLoss
-------------------------------
**版本升级,文档正在开发中**
.. _cn_api_tensor_add:
add
-------------------------------
.. py:function:: paddle.add(x, y, alpha=1, out=None, name=None)
该OP是逐元素相加算子,输入 ``x`` 与输入 ``y`` 逐元素相加,并将各个位置的输出元素保存到返回结果中。
等式为:
.. math::
Out = X + Y
- :math:`X` :多维Tensor。
- :math:`Y` :维度必须小于等于X维度的Tensor。
对于这个运算算子有2种情况:
1. :math:`Y` 的 ``shape`` 与 :math:`X` 相同。
2. :math:`Y` 的 ``shape`` 是 :math:`X` 的连续子序列。
对于情况2:
1. 用 :math:`Y` 匹配 :math:`X` 的形状(shape),其中 ``axis`` 是 :math:`Y` 在 :math:`X` 上的起始维度的位置。
2. 如果 ``axis`` 为-1(默认值),则 :math:`axis= rank(X)-rank(Y)` 。
3. 考虑到子序列, :math:`Y` 的大小为1的尾部维度将被忽略,例如shape(Y)=(2,1)=>(2)。
例如:
.. code-block:: text
shape(X) = (2, 3, 4, 5), shape(Y) = (,)
shape(X) = (2, 3, 4, 5), shape(Y) = (5,)
shape(X) = (2, 3, 4, 5), shape(Y) = (4, 5), with axis=-1(default) or axis=2
shape(X) = (2, 3, 4, 5), shape(Y) = (3, 4), with axis=1
shape(X) = (2, 3, 4, 5), shape(Y) = (2), with axis=0
shape(X) = (2, 3, 4, 5), shape(Y) = (2, 1), with axis=0
参数:
- **x** (Variable)- 多维 ``Tensor`` 或 ``LoDTensor`` 。数据类型为 ``float32`` 、 ``float64`` 、 ``int32`` 或 ``int64``。
- **y** (Variable)- 多维 ``Tensor`` 或 ``LoDTensor`` 。数据类型为 ``float32`` 、 ``float64`` 、 ``int32`` 或 ``int64``。
- **alpha** (int|float,可选)- 输入y的缩放因子。默认值为1. 如果alpha不为1,本api计算公式变为 :math:`Out = X + alpha * Y`
- **out** (Variable,可选)- 指定存储运算结果的 ``Tensor`` 。如果设置为None或者不设置,将创建新的 ``Tensor`` 存储运算结果,默认值为None。
- **name** (str,可选)- 输出的名字。默认值为None。该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` 。
返回: 多维 ``Tensor`` 或 ``LoDTensor`` ,维度和数据类型都与 ``x`` 相同。
返回类型: Variable
**代码示例 1**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z1 = paddle.add(x, y)
z2 = paddle.add(x, y, alpha=10)
# z = x + y
place = fluid.CPUPlace()
exe = fluid.Executor(place)
z_value = exe.run(feed=gen_data(),
fetch_list=[z1.name, z2.name])
print(z_value[0]) # [3., 8., 6.]
print(z_value[1]) # [12. 53. 24.]
**代码示例 2**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((4, 5)).astype('float32')
}
x = fluid.data(name="x", shape=[2, 3, 4, 5], dtype='float32')
y = fluid.data(name="y", shape=[4, 5], dtype='float32')
z = paddle.add(x, y, name='z')
# z = x + y
place = fluid.CPUPlace()
exe = fluid.Executor(place)
z_value = exe.run(feed=gen_data(),
fetch_list=[z.name])
print(z_value[0])
print(z_value[0].shape) # z.shape=[2,3,4,5]
**代码示例 3**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
def gen_data():
return {
"x": np.random.randint(1, 5, size=[2, 3, 4, 5]).astype('float32'),
"y": np.random.randint(1, 5, size=[5]).astype('float32')
}
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[5], dtype='float32')
z = paddle.add(x, y)
# z = x / y
place = fluid.CPUPlace()
exe = fluid.Executor(place)
z_value = exe.run(feed=gen_data(),
fetch_list=[z.name])
print(z_value[0])
print(z_value[0].shape) # z.shape=[2,3,4,5]
**代码示例 4**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
x = fluid.data(name="x", shape=[3], dtype="float32")
y = fluid.data(name='y', shape=[3], dtype='float32')
output = fluid.data(name="output", shape=[3], dtype="float32")
z = paddle.add(x, y, out=output)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
data1 = np.array([2, 3, 4], dtype='float32')
data2 = np.array([1, 5, 2], dtype='float32')
z_value = exe.run(feed={'x': data1,
'y': data2},
fetch_list=[z])
print(z_value[0]) # [3. 8. 6.]
**代码示例 5(动态图)**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
with fluid.dygraph.guard():
np_x = np.array([2, 3, 4]).astype('float64')
np_y = np.array([1, 5, 2]).astype('float64')
x = fluid.dygraph.to_variable(np_x)
y = fluid.dygraph.to_variable(np_y)
z = paddle.add(x, y, alpha=-0.5)
np_z = z.numpy()
print(np_z) # [1.5, 0.5, 3. ]
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
addcmul addcmul
------------------------------- -------------------------------
.. py:function:: paddle.fluid.layers.addcmul(input, tensor1, tensor2, value=1.0, out=None, name=None) .. py:function:: paddle.addcmul(input, tensor1, tensor2, value=1.0, out=None, name=None)
计算tensor1和tensor2的逐元素乘积,然后将结果乘以标量value,再加到input上输出。其中input, tensor1, tensor2的维度必须是可广播的。 计算tensor1和tensor2的逐元素乘积,然后将结果乘以标量value,再加到input上输出。其中input, tensor1, tensor2的维度必须是可广播的。
...@@ -33,5 +33,5 @@ addcmul ...@@ -33,5 +33,5 @@ addcmul
input = fluid.data(name='input', dtype='float32', shape=[3, 4]) input = fluid.data(name='input', dtype='float32', shape=[3, 4])
tensor1 = fluid.data(name='tenosr1', dtype='float32', shape=[1, 4]) tensor1 = fluid.data(name='tenosr1', dtype='float32', shape=[1, 4])
tensor2 = fluid.data(name='tensor2', dtype='float32', shape=[3, 4]) tensor2 = fluid.data(name='tensor2', dtype='float32', shape=[3, 4])
data = fluid.layers.addcmul(input, tensor1, tensor2, value=1.0) data = paddle.addcmul(input, tensor1, tensor2, value=1.0)
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
arange arange
------------------------------- -------------------------------
.. py:function:: paddle.fluid.layers.arange(start, end, step=1, dtype=None, name=None) .. py:function:: paddle.tensor.arange(start, end, step=1, dtype=None, name=None)
该API根据step均匀分隔给定数值区间[start, end),并返回该分隔结果。 该API根据step均匀分隔给定数值区间[start, end),并返回该分隔结果。
...@@ -24,6 +24,6 @@ arange ...@@ -24,6 +24,6 @@ arange
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
with fluid.dygraph.guard(): with fluid.dygraph.guard():
x = fluid.layers.arange(0, 6, 2) x = paddle.arange(0, 6, 2)
# x: [0, 2, 4] # x: [0, 2, 4]
# x dtype: float32 # x dtype: float32
.. _cn_api_tensor_argmax:
argmax
-------------------------------
.. py:function:: paddle.argmax(input, axis=None, dtype=None, out=None, keepdims=False, name=None)
该OP沿 ``axis`` 计算输入 ``input`` 的最大元素的索引。
参数:
- **input** (Variable) - 输入的多维 ``Tensor`` ,支持的数据类型:float32、float64、int8、int16、int32、int64。
- **axis** (int,可选) - 指定对输入Tensor进行运算的轴, ``axis`` 的有效范围是[-R, R),R是输入 ``input`` 的Rank, ``axis`` -R与绝对值相同的R等价。默认值为0。
- **dtype** (np.dtype|core.VarDesc.VarType|str)- 输出Tensor的数据类型,可选值为int32,int64,默认值为None,将返回int64类型的结果。
- **out** (Variable, 可选) – 指定存储运算结果的Tensor。如果设置为None或者不设置,将创建新的Tensor存储运算结果,默认值为None。
- **keepdims** (bool,可选)- 是否保留进行max index操作的维度,默认值为False。
- **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。
返回: ``Tensor`` ,数据类型int64
返回类型:Variable
**代码示例**:
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
in1 = np.array([[[5,8,9,5],
[0,0,1,7],
[6,9,2,4]],
[[5,2,4,2],
[4,7,7,9],
[1,7,0,6]]])
with fluid.dygraph.guard():
x = fluid.dygraph.to_variable(in1)
out1 = paddle.argmax(input=x, axis=-1)
out2 = paddle.argmax(input=x, axis=0)
out3 = paddle.argmax(input=x, axis=1)
out4 = paddle.argmax(input=x, axis=2)
out5 = paddle.argmax(input=x, axis=2, keepdims=True)
print(out1.numpy())
# [[2 3 1]
# [0 3 1]]
print(out2.numpy())
# [[0 0 0 0]
# [1 1 1 1]
# [0 0 0 1]]
print(out3.numpy())
# [[2 2 0 1]
# [0 1 1 1]]
print(out4.numpy())
# [[2 3 1]
# [0 3 1]]
print(out5.numpy())
#array([[[2],
# [3],
# [1]],
# [[0],
# [3],
# [1]]])
.. _cn_api_tensor_atan:
atan
-------------------------------
.. py:function:: paddle.atan(x, name=None, out=None)
arctanh 激活函数。
.. math::
out = tanh^{-1}(x)
参数:
- **x(Variable)** - atan的输入Tensor,数据类型为 float32 或 float64
- **name** (str|None) – 具体用法请参见 :ref:`cn_api_guide_Name` ,一般无需设置,默认值为None。
- **out** (Variable, 可选) – 指定存储运算结果的Tensor。如果设置为None或者不设置,将创建新的Tensor存储运算结果,默认值为None。
返回:返回类型为Variable(Tensor|LoDTensor), 数据类型同输入一致。
**代码示例**:
.. code-block:: python
import numpy as np
import paddle
import paddle.fluid as fluid
inputs = fluid.layers.data(name="x", shape = [3], dtype='float32')
output = paddle.atan(inputs)
exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_startup_program())
img = np.array([-0.8183, 0.4912, -0.6444, 0.0371]).astype(np.float32)
res = exe.run(fluid.default_main_program(), feed={'x':img}, fetch_list=[output])
print(res)
#[array([-0.6858003, 0.45658287, -0.5724284, 0.03708299], dtype=float32)]
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
bmm bmm
------------------------------- -------------------------------
.. py:function:: paddle.fluid.layers.bmm(x, y, name=None): .. py:function:: paddle.tensor.bmm(x, y, name=None):
对输入x及输入y进行矩阵相乘。 对输入x及输入y进行矩阵相乘。
...@@ -38,7 +38,7 @@ bmm ...@@ -38,7 +38,7 @@ bmm
with fluid.dygraph.guard(): with fluid.dygraph.guard():
x = fluid.dygraph.to_variable(input1) x = fluid.dygraph.to_variable(input1)
y = fluid.dygraph.to_variable(input2) y = fluid.dygraph.to_variable(input2)
out = fluid.layers.bmm(x, y) out = paddle.bmm(x, y)
#output size: (2, 2, 2) #output size: (2, 2, 2)
#output value: #output value:
#[[[6.0, 6.0],[12.0, 12.0]],[[45.0, 45.0],[60.0, 60.0]]] #[[[6.0, 6.0],[12.0, 12.0]],[[45.0, 45.0],[60.0, 60.0]]]
......
cholesky
-------------------------------
**版本升级,文档正在开发中**
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
clamp clamp
------------------------------- -------------------------------
.. py:function:: paddle.fluid.layers.clamp(input, min=None, max=None, output=None, name=None) .. py:function:: paddle.clamp(input, min=None, max=None, output=None, name=None)
该OP将输入的所有元素进行剪裁,使得输出元素限制在[min, max]内,具体公式如下: 该OP将输入的所有元素进行剪裁,使得输出元素限制在[min, max]内,具体公式如下:
...@@ -34,8 +34,8 @@ clamp ...@@ -34,8 +34,8 @@ clamp
[4.5,6.4]]).astype('float32') [4.5,6.4]]).astype('float32')
with fluid.dygraph.guard(): with fluid.dygraph.guard():
x1 = fluid.dygraph.to_variable(in1) x1 = fluid.dygraph.to_variable(in1)
out1 = fluid.layers.clamp(x1, min=3.5, max=5.0) out1 = paddle.tensor.clamp(x1, min=3.5, max=5.0)
out2 = fluid.layers.clamp(x1, min=2.5) out2 = paddle.tensor.clamp(x1, min=2.5)
print(out1.numpy()) print(out1.numpy())
# [[3.5, 3.5] # [[3.5, 3.5]
# [4.5, 5.0]] # [4.5, 5.0]]
......
concat
-------------------------------
**版本升级,文档正在开发中**
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
cross cross
------------------------------- -------------------------------
.. py:function:: paddle.fluid.layers.cross(input, other, dim=None) .. py:function:: paddle.cross(input, other, dim=None)
该OP返回在 ``dim`` 维度上,两个张量 ``input`` 和 ``other`` 的向量积(叉积)。 ``input`` 和 ``other`` 必须有相同的形状, 该OP返回在 ``dim`` 维度上,两个张量 ``input`` 和 ``other`` 的向量积(叉积)。 ``input`` 和 ``other`` 必须有相同的形状,
且指定的 ``dim`` 维上 ``size`` 必须为3,如果 ``dim`` 未指定,默认选取第一个 ``size`` 等于3的维度。 且指定的 ``dim`` 维上 ``size`` 必须为3,如果 ``dim`` 未指定,默认选取第一个 ``size`` 等于3的维度。
...@@ -34,12 +34,12 @@ cross ...@@ -34,12 +34,12 @@ cross
with fluid.dygraph.guard(): with fluid.dygraph.guard():
x = fluid.dygraph.to_variable(data_x) x = fluid.dygraph.to_variable(data_x)
y = fluid.dygraph.to_variable(data_y) y = fluid.dygraph.to_variable(data_y)
out_z1 = fluid.layers.cross(x, y) out_z1 = paddle.cross(x, y)
print(out_z1.numpy()) print(out_z1.numpy())
#[[-1. -1. -1.] #[[-1. -1. -1.]
# [ 2. 2. 2.] # [ 2. 2. 2.]
# [-1. -1. -1.]] # [-1. -1. -1.]]
out_z2 = fluid.layers.cross(x, y, dim=1) out_z2 = paddle.cross(x, y, dim=1)
print(out_z2.numpy()) print(out_z2.numpy())
#[[0. 0. 0.] #[[0. 0. 0.]
# [0. 0. 0.] # [0. 0. 0.]
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
dist dist
------------------------------- -------------------------------
.. py:function:: paddle.fluid.layers.linalg.dist(x, y, p=2) .. py:function:: paddle.tensor.linalg.dist(x, y, p=2)
该OP用于计算 `(x-y)` 的 p 范数(p-norm),需要注意这不是严格意义上的范数,仅作为距离的度量。输入 `x` 和 `y` 的形状(shape)必须是可广播的(broadcastable)。其含义如下,详情请参考 `numpy的广播概念 <https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html>`_ : 该OP用于计算 `(x-y)` 的 p 范数(p-norm),需要注意这不是严格意义上的范数,仅作为距离的度量。输入 `x` 和 `y` 的形状(shape)必须是可广播的(broadcastable)。其含义如下,详情请参考 `numpy的广播概念 <https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html>`_ :
...@@ -65,11 +65,11 @@ z (4-D Tensor): 8 x 7 x 6 x 5 ...@@ -65,11 +65,11 @@ z (4-D Tensor): 8 x 7 x 6 x 5
with fluid.dygraph.guard(): with fluid.dygraph.guard():
x = fluid.dygraph.to_variable(np.array([[3, 3],[3, 3]]).astype(np.float32)) x = fluid.dygraph.to_variable(np.array([[3, 3],[3, 3]]).astype(np.float32))
y = fluid.dygraph.to_variable(np.array([[3, 3],[3, 1]]).astype(np.float32)) y = fluid.dygraph.to_variable(np.array([[3, 3],[3, 1]]).astype(np.float32))
out = fluid.layers.dist(x, y, 0) out = paddle.dist(x, y, 0)
print(out.numpy()) # out = [1.] print(out.numpy()) # out = [1.]
out = fluid.layers.dist(x, y, 2) out = paddle.dist(x, y, 2)
print(out.numpy()) # out = [2.] print(out.numpy()) # out = [2.]
out = fluid.layers.dist(x, y, float("inf")) out = paddle.dist(x, y, float("inf"))
print(out.numpy()) # out = [2.] print(out.numpy()) # out = [2.]
out = fluid.layers.dist(x, y, float("-inf")) out = paddle.dist(x, y, float("-inf"))
print(out.numpy()) # out = [0.] print(out.numpy()) # out = [0.]
.. _cn_api_tensor_div:
div
-------------------------------
.. py:function:: paddle.div(x, y, out=None, name=None)
该OP是逐元素相除算子,输入 ``x`` 与输入 ``y`` 逐元素相除,并将各个位置的输出元素保存到返回结果中。
等式是:
.. math::
Out = X / Y
- :math:`X` :多维Tensor。
- :math:`Y` :维度必须小于等于X维度的Tensor。
对于这个运算算子有2种情况:
1. :math:`Y` 的 ``shape`` 与 :math:`X` 相同。
2. :math:`Y` 的 ``shape`` 是 :math:`X` 的连续子序列。
对于情况2:
1. 用 :math:`Y` 匹配 :math:`X` 的形状(shape),其中 ``axis`` 是 :math:`Y` 在 :math:`X` 上的起始维度的位置。
2. 如果 ``axis`` 为-1(默认值),则 :math:`axis= rank(X)-rank(Y)` 。
3. 考虑到子序列, :math:`Y` 的大小为1的尾部维度将被忽略,例如shape(Y)=(2,1)=>(2)。
例如:
.. code-block:: text
shape(X) = (2, 3, 4, 5), shape(Y) = (,)
shape(X) = (2, 3, 4, 5), shape(Y) = (5,)
shape(X) = (2, 3, 4, 5), shape(Y) = (4, 5), with axis=-1(default) or axis=2
shape(X) = (2, 3, 4, 5), shape(Y) = (3, 4), with axis=1
shape(X) = (2, 3, 4, 5), shape(Y) = (2), with axis=0
shape(X) = (2, 3, 4, 5), shape(Y) = (2, 1), with axis=0
参数:
- **x** (Variable)- 多维 ``Tensor`` 或 ``LoDTensor`` 。数据类型为 ``float32`` 、 ``float64`` 、 ``int32`` 或 ``int64``。
- **y** (Variable)- 多维 ``Tensor`` 或 ``LoDTensor`` 。数据类型为 ``float32`` 、 ``float64`` 、 ``int32`` 或 ``int64``。
- **out** (Variable,可选)- 指定存储运算结果的 ``Tensor`` 。如果设置为None或者不设置,将创建新的 ``Tensor`` 存储运算结果,默认值为None。
- **name** (str,可选)- 输出的名字。默认值为None。该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` 。
返回: 多维 ``Tensor`` 或 ``LoDTensor`` , 维度和数据类型都与 ``x`` 相同。
返回类型: Variable
**代码示例 1**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = paddle.div(x, y)
# z = x / y
place = fluid.CPUPlace()
exe = fluid.Executor(place)
z_value = exe.run(feed=gen_data(),
fetch_list=[z.name])
print(z_value) # [2., 0.6, 2.]
**代码示例 2**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((4, 5)).astype('float32')
}
x = fluid.data(name="x", shape=[2, 3, 4, 5], dtype='float32')
y = fluid.data(name="y", shape=[4, 5], dtype='float32')
z = paddle.div(x, y, name='z')
# z = x / y
place = fluid.CPUPlace()
exe = fluid.Executor(place)
z_value = exe.run(feed=gen_data(),
fetch_list=[z.name])
print(z_value[0])
print(z_value[0].shape) # z.shape=[2,3,4,5]
**代码示例 3**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
def gen_data():
return {
"x": np.random.randint(1, 5, size=[2, 3, 4, 5]).astype('float32'),
"y": np.random.randint(1, 5, size=[5]).astype('float32')
}
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[5], dtype='float32')
output = fluid.data(name="output", shape=[2,3,4,5], dtype="float32")
z = paddle.div(x, y, out=output)
# z = x / y
place = fluid.CPUPlace()
exe = fluid.Executor(place)
z_value = exe.run(feed=gen_data(),
fetch_list=[z.name])
print(z_value[0])
print(z_value[0].shape) # z.shape=[2,3,4,5]
**代码示例 4(动态图)**
.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
with fluid.dygraph.guard(fluid.CPUPlace()):
np_x = np.array([2, 3, 4]).astype('float64')
np_y = np.array([1, 5, 2]).astype('float64')
x = fluid.dygraph.to_variable(np_x)
y = fluid.dygraph.to_variable(np_y)
z = paddle.div(x, y)
np_z = z.numpy()
print(np_z) # [2., 0.6, 2.]
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
dot dot
------------------------------- -------------------------------
.. py:function:: paddle.fluid.layers.dot(x, y, name=None) .. py:function:: paddle.tensor.linalg.dot(x, y, name=None)
该OP计算向量的内积 该OP计算向量的内积
...@@ -31,7 +31,7 @@ dot ...@@ -31,7 +31,7 @@ dot
with fluid.dygraph.guard(): with fluid.dygraph.guard():
x = fluid.dygraph.to_variable(np.random.uniform(0.1, 1, [10]).astype(np.float32)) x = fluid.dygraph.to_variable(np.random.uniform(0.1, 1, [10]).astype(np.float32))
y = fluid.dygraph.to_variable(np.random.uniform(1, 3, [10]).astype(np.float32)) y = fluid.dygraph.to_variable(np.random.uniform(1, 3, [10]).astype(np.float32))
z = fluid.layers.dot(x, y) z = paddle.dot(x, y)
print(z.numpy()) print(z.numpy())
einsum
-------------------------------
**版本升级,文档正在开发中**
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
elementwise_equal elementwise_equal
------------------------------- -------------------------------
.. py:function:: paddle.fluid.layers.elementwise_equal(x, y, name=None) .. py:function:: paddle.elementwise_equal(x, y, name=None)
该OP返回 :math:`x==y` 逐元素比较x和y是否相等。 该OP返回 :math:`x==y` 逐元素比较x和y是否相等。
...@@ -26,4 +26,4 @@ elementwise_equal ...@@ -26,4 +26,4 @@ elementwise_equal
label = fluid.layers.assign(np.array([3, 3], dtype="int32")) label = fluid.layers.assign(np.array([3, 3], dtype="int32"))
limit = fluid.layers.assign(np.array([3, 2], dtype="int32")) limit = fluid.layers.assign(np.array([3, 2], dtype="int32"))
out1 = fluid.layers.elementwise_equal(x=label, y=limit) #out1=[True, False] out1 = paddle.elementwise_equal(x=label, y=limit) #out1=[True, False]
.. _cn_api_tensor_elementwise_sum:
elementwise_sum
-------------------------------
.. py:function:: paddle.elementwise_sum(inputs, name=None)
该OP用于对输入的一至多个Tensor或LoDTensor求和。如果输入的是LoDTensor,输出仅与第一个输入共享LoD信息(序列信息)。
例1:
::
输入:
input.shape = [2, 3]
input = [[1, 2, 3],
[4, 5, 6]]
输出:
output.shape = [2, 3]
output = [[1, 2, 3],
[4, 5, 6]]
例2:
::
输入:
第一个输入:
input1.shape = [2, 3]
input1 = [[1, 2, 3],
[4, 5, 6]]
第二个输入:
input2.shape = [2, 3]
input2 = [[7, 8, 9],
[10, 11, 12]]
输出:
output.shape = [2, 3]
output = [[8, 10, 12],
[14, 16, 18]]
参数:
- **inputs** (Variable|list(Variable)) - 输入的一至多个Variable。如果输入了多个Variable,则不同Variable间的shape和数据类型应保持一致。Variable为多维Tensor或LoDTensor,数据类型支持:float32,float64,int32,int64。
- **name** (str,可选)- 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。
返回:对输入 ``inputs`` 中的Variable求和后的结果,shape和数据类型与 ``inputs`` 一致。
返回类型:Variable
**代码示例:**
.. code-block:: python
import paddle
import paddle.fluid as fluid
input0 = fluid.layers.fill_constant(shape=[2, 3], dtype='int64', value=5)
input1 = fluid.layers.fill_constant(shape=[2, 3], dtype='int64', value=3)
sum = paddle.elementwise_sum([input0, input1])
#用户可以通过executor打印出求和的结果
out = fluid.layers.Print(sum, message="the sum of input0 and input1: ")
exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_main_program())
#打印出的数据为:
1570701754 the sum of input0 and input1: The place is:CPUPlace
Tensor[elementwise_sum_0.tmp_0]
shape: [2,3,]
dtype: l
data: 8,8,8,8,8,8,
#输出了shape为[2,3]的Tensor,与输入的shape一致
#dtype为对应C++数据类型,在不同环境下可能显示值不同,但本质相同
#例如:如果Tensor中数据类型是int64,则对应的C++数据类型为int64_t,所以dtype值为typeid(int64_t).name(),
# 其在MacOS下为'x',linux下为'l',Windows下为'__int64',都表示64位整型变量
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册