Skip to content
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions doc/design/initialization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Initialization of Parameters

## Motivation

PaddlePaddle needs a way to init parameters.

## Challenge

Initialization operators must run once and only one; otherwise, every iteration would clear the parameters.

## Proposals

### Proposal 1: Two seperate `ProgramDesc`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems simple and workable.

The resource which survived across multiple block/program is the Variables in Scopes.

A program is the container of multiple Blocks, more than one program seems not a problem.


The initialization part of the program in a `ProgramDesc` message, and the rest part in another.

- Pros:
- Simple and straight forward.
- Cons:
- Two seperate `ProgramDesc` doesn't match one-program-desc design.

### Proposal 2: Add `run_once` attribute for initialization related operators.

PR link: https://github.com/PaddlePaddle/Paddle/pull/4802/files

- Pros:
- Simple and straight forward
- Cons:
- Not compatible with current executor design. Because executor creates Op instances on the fly at `Executor::Run()`.

### Proposal 3: Remove Init operator during Prune

Use regular expression to filter out init operators.

API at prune.cc
```c++
Prune(const ProgramDesc& input, ProgramDesc* output, const PruneInfo& prune_msg);
```

Add protobuf message
```protobuf
message PruneInfo {
repeated string re = 3; // regular expression, e.g. "init_*".
}
```

- Pros:
- Extendible