|
|
|
@ -398,7 +398,26 @@ All parameter, weight, gradient are variables in Paddle.
|
|
|
|
|
},
|
|
|
|
|
py::return_value_policy::copy);
|
|
|
|
|
|
|
|
|
|
py::class_<Scope>(m, "Scope", "")
|
|
|
|
|
py::class_<Scope>(m, "Scope", R"DOC(
|
|
|
|
|
Scope is an association of a name to Variable. All variables belong to Scope.
|
|
|
|
|
|
|
|
|
|
Variables in a parent scope can be retrieved from local scope.
|
|
|
|
|
|
|
|
|
|
You need to specify a scope to run a Net, i.e., `exe.Run(&scope)`.
|
|
|
|
|
One net can run in different scopes and update different variable in the
|
|
|
|
|
scope.
|
|
|
|
|
|
|
|
|
|
You can create var in a scope and get it from the scope.
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
# create tensor from a scope and set value to it.
|
|
|
|
|
param = scope.var('Param').get_tensor()
|
|
|
|
|
param_array = np.full((height, row_numel), 5.0).astype("float32")
|
|
|
|
|
param.set(param_array, place)
|
|
|
|
|
|
|
|
|
|
)DOC")
|
|
|
|
|
.def("var",
|
|
|
|
|
[](Scope &self, const std::string &name) -> Variable * {
|
|
|
|
|
return self.Var(name);
|
|
|
|
|