MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / list_vars

Method list_vars

python/paddle/base/framework.py:7443–7469  ·  view source on GitHub ↗

Get all Tensors from this Program. A iterable object is returned. Returns: iterable Tensors: The Generator will yield every Tensor in this program. Examples: .. code-block:: pycon >>> # doctest: +SKIP("This has diff in xdoctest env"

(self)

Source from the content-addressed store, hash-verified

7441 dst_op.struct_name = src_op.struct_name
7442
7443 def list_vars(self):
7444 """
7445 Get all Tensors from this Program. A iterable object is returned.
7446
7447 Returns:
7448 iterable Tensors: The Generator will yield every Tensor in this program.
7449
7450 Examples:
7451 .. code-block:: pycon
7452
7453 >>> # doctest: +SKIP("This has diff in xdoctest env")
7454 >>> import paddle
7455 >>> import paddle.static as static
7456
7457 >>> paddle.enable_static()
7458
7459 >>> prog = static.default_main_program()
7460 >>> img = static.data(name='img', shape=[None, 1, 28, 28], dtype='float32')
7461 >>> label = static.data(name='label', shape=[None, 1], dtype='int64')
7462 >>> for var in prog.list_vars():
7463 ... print(var)
7464
7465 >>> # var img : DENSE_TENSOR.shape(-1, 1, 28, 28).dtype(float32).stop_gradient(True)
7466 >>> # var label : DENSE_TENSOR.shape(-1, 1).dtype(int64).stop_gradient(True)
7467 """
7468 for each_block in self.blocks:
7469 yield from list(each_block.vars.values())
7470
7471 def all_parameters(self):
7472 """

Callers 15

state_dictMethod · 0.95
set_state_dictMethod · 0.95
_serialize_persistablesFunction · 0.80
save_inference_modelFunction · 0.80
deserialize_persistablesFunction · 0.80
load_inference_modelFunction · 0.80
save_varsFunction · 0.80
load_varsFunction · 0.80
saveFunction · 0.80
loadFunction · 0.80
set_program_stateFunction · 0.80

Calls 2

listFunction · 0.85
valuesMethod · 0.45