Conversation
doc/design/optimizer.md
Outdated
| op related. | ||
| """ | ||
| ... | ||
| return update_op |
There was a problem hiding this comment.
When a user wants to update twice, the update_op need to trace the first update_op and all update, backward op related. Maybe we need to write some guides to point out it.
There was a problem hiding this comment.
ok, after discussing with @dzhwinter , this can be done in the current design, but not the most important thing to consider now.
There was a problem hiding this comment.
have already make the backward interface public, user and call it directly multiple times to create more gradient operators in the graph.
doc/design/optimizer.md
Outdated
| @@ -0,0 +1,85 @@ | |||
| ## Optimizer Design | |||
| In deeplearning system, `Optimizer` is used to optimize(minimize) loss thow updating a list of parameters. | |||
doc/design/optimizer.md
Outdated
|
|
||
| ### A typical training process: | ||
|
|
||
| 1. run forward to calculate activation using data and parameter. |
There was a problem hiding this comment.
I do not think this typical training process fits our current design.
Currently, we put every operator into one ProgramDesc. There are not three running stages explicitly.
There was a problem hiding this comment.
This is a general abstract training process, no matter how complex the training process is, they are all composed of these stages.
In Our design, we also have functions like backward and optimize to put related operators into ProgramDesc. Here we just put the interface into Optimizer as high level API.
doc/design/optimizer.md
Outdated
|
|
||
| ```python | ||
| class Optimizer(object): | ||
| def _backward(loss): |
There was a problem hiding this comment.
backward and update should be public.
doc/design/optimizer.md
Outdated
| 3. User use the optimizer to `minimize` a certain `cost` thow updating parameters in parameter_list. | ||
|
|
||
| ```python | ||
| opt = optimizer.minimize(cost, parameter_list=[w1, ...]) |
doc/design/optimizer.md
Outdated
| @@ -0,0 +1,85 @@ | |||
| ## Optimizer Design | |||
| In deeplearning system, `Optimizer` is used to optimize(minimize) loss thow updating a list of parameters. | |||
There was a problem hiding this comment.
This design doc doesn't explain the challenge.
It looks to me that the challenge is
The Problem
A PaddlePaddle program, or a block, is a sequence of operators operating variables. A training program needs to do three kinds of works:
- the forward pass, which computes intermediate results and the cost(s),
- the backward pass, which derives gradients from intermediate and costs, and
- the optimization pass, which update model parameters.
These works rely on three kinds of operators:
- forward operators,
- gradient operators, and
- optimization operators.
It's true that users should be able to create all these operators manually by calling some low-level API, but it would be much more convenient if they could only describe the forward pass and let PaddlePaddle create the backward and optimization operators automatically.
In this design, we propose a high-level API that automatically derives the optimisation pass and operators from the forward pass.
doc/design/optimizer.md
Outdated
| ## Optimizer Design | ||
| In deeplearning system, `Optimizer` is used to optimize(minimize) loss thow updating a list of parameters. | ||
|
|
||
| ### A typical training process: |
There was a problem hiding this comment.
If the above proposed section ## The Problem is accepted, this paragraph of three bullets can be removed.
doc/design/optimizer.md
Outdated
|
|
||
| 1. User write code to describe the network: | ||
|
|
||
| ```python |
There was a problem hiding this comment.
This Python program needs to be properly indented -- to the right of 1. in the above line.
doc/design/optimizer.md
Outdated
| cost = layer.mse(hidden, labels) | ||
| ``` | ||
|
|
||
| the code above will generate forward operators in [block](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/block.md). |
There was a problem hiding this comment.
the => The
the code above => The above code snippet
will generate => creates
doc/design/optimizer.md
Outdated
| the code above will generate forward operators in [block](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/block.md). | ||
|
|
||
|
|
||
| 2. User create a Optimizer and set parameter list that it need to update. |
There was a problem hiding this comment.
Either The user creates or Users create
doc/design/optimizer.md
Outdated
|
|
||
| 2. User create a Optimizer and set parameter list that it need to update. | ||
|
|
||
| ```python |
There was a problem hiding this comment.
Correct code snippet indentation in the Markdown doc.
doc/design/optimizer.md
Outdated
|
|
||
| ### What does optimizer do: | ||
|
|
||
| In PaddlePaddle, we use block of operators to describe computation. From the Python Interface we described above, we can see that `Optimizer` should add some operators to the computation block: |
There was a problem hiding this comment.
block of operators => blocks of operators
we use => PaddlePaddle uses
doc/design/optimizer.md
Outdated
|
|
||
| ```python | ||
| class Optimizer(object): | ||
| def _backward(loss): |
There was a problem hiding this comment.
_backward => create_backward_pass
doc/design/optimizer.md
Outdated
| ... | ||
| return variables | ||
|
|
||
| def _update(var_list): |
There was a problem hiding this comment.
_update => create_optimization_pass
|
|
||
| 1. User write code to describe the network: | ||
|
|
||
| ```python |
There was a problem hiding this comment.
the pseudo code here not format well.
doc/design/optimizer.md
Outdated
|
|
||
| ```python | ||
| class Optimizer(object): | ||
| def create_backward_pass(loss, parameter_list=None): |
There was a problem hiding this comment.
Parameter and variable look like interchangeable in Python API. Not sure they are referred to the same concept.
doc/design/optimizer.md
Outdated
| This method simply combines calls `create_backward_pass()` and | ||
| `create_optimization_pass()`. | ||
| """ | ||
| vars_grads = create_backward_pass(loss) |
There was a problem hiding this comment.
typo create_backward_pass(loss) => create_backward_pass(loss, parameter_list)
|
The reason of use a uniform interface for Optimizer.
|
issue: #4679