Skip to content

Commit

Permalink
Upadte docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KazusaW1999 authored Jul 9, 2021
1 parent 0adef44 commit 5b50bf0
Show file tree
Hide file tree
Showing 10 changed files with 1,979 additions and 562 deletions.
1 change: 1 addition & 0 deletions docs/apis/backbones/backbones.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
English | [简体中文](backbones_cn.md)
# paddleseg.models.backbone

The models subpackage contains backbones extracting features for sementic segmentation models.
Expand Down
1 change: 1 addition & 0 deletions docs/apis/backbones/backbones_cn.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
简体中文 | [English](backbones.md)
# paddleseg.models.backbone

该models子包中包含了为语义分割模型提取特征的骨干网络。
Expand Down
1 change: 1 addition & 0 deletions docs/apis/core/core.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
English | [简体中文](core_cn.md)
# paddleseg.core

The interface for training, evaluation and prediction.
Expand Down
1 change: 1 addition & 0 deletions docs/apis/core/core_cn.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
简体中文 | [English](core.md)
# paddleseg.core

启动模型训练,评估与预测的接口
Expand Down
154 changes: 81 additions & 73 deletions docs/apis/cvlibs/cvlibs.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
English | [简体中文](cvlibs_cn.md)
# paddleseg.cvlibs

- [Manager](#Manager)
- [Parameters Initialization](#parameters-initialization)
- [ComponentManager](#ComponentManager)
- [constant_init](#constant_init)
- [Config](#Config)


## [Manager](../../paddleseg/cvlibs/manager.py)
> CLASS paddleseg.cvlibs.manager.ComponentManager(name)
Implement a manager class to add the new component properly.
The component can be added as either class or function type.
## [ComponentManager](../../../paddleseg/cvlibs/manager.py)
```python
class paddleseg.cvlibs.manager.ComponentManager(name)
```
> Implement a Manager class to correctly add new components to the model.
> Components are added as classes or functions.
> > Args
> > > - **name** (str): The name of component.
### Args
* **name** (str): The name of component.

> > Examples 1
### Examples 1

```python
from paddleseg.cvlibs.manager import ComponentManager
Expand All @@ -33,7 +35,7 @@ print(model_manager.components_dict)
# {'AlexNet': <class '__main__.AlexNet'>, 'ResNet': <class '__main__.ResNet'>}
```

> > Examples 2:
### Examples 2:

```python
# Or an easier way, using it as a Python decorator, while just add it above the class declaration.
Expand All @@ -51,28 +53,28 @@ print(model_manager.components_dict)
# {'AlexNet': <class '__main__.AlexNet'>, 'ResNet': <class '__main__.ResNet'>}
```

> > add_component(components)
Add component(s) into the corresponding manager.

> > > Args
> > > > - **components** (function|class|list|tuple): Support four types of components.
> > Returns
> > > > - **components** (function|class|list|tuple): Same with input components.
```python
add_component(components)
```
> Add component(s) into the corresponding manager.
## [Parameters Initialization](../../paddleseg/cvlibs/param_init.py)
initialization method
### Args
* **components** (function|class|list|tuple): Support four types of components.
### Returns
* **components** (function|class|list|tuple): Same with input components.

### Constant Initialization

> constant_init(param, **kwargs):
## [constant_init](../../../paddleseg/cvlibs/param_init.py)

Initialize the `param` with constants.
```python
constant_init(param, **kwargs):
```
> Initialize the `param` with constants.
> > Args
> > > - **param** (Tensor): Tensor that needs to be initialized.
### Args
* **param** (Tensor): Tensor that needs to be initialized.

> > Examples
### Examples

```python
from paddleseg.cvlibs import param_init
Expand All @@ -84,15 +86,17 @@ print(linear.weight.numpy())
# result is [[2. 2. 2. 2.], [2. 2. 2. 2.]]
```

### Normal Initialization
> normal_init(param, **kwargs)
### [normal_init](../../../paddleseg/cvlibs/param_init.py)
```python
normal_init(param, **kwargs)
```

Initialize the `param` with a Normal distribution.

> > Args
> > > - **param** (Tensor): Tensor that needs to be initialized.
### Args
* **param** (Tensor): Tensor that needs to be initialized.

> > Examples
### Examples

```python
from paddleseg.cvlibs import param_init
Expand All @@ -102,28 +106,30 @@ linear = nn.Linear(2, 4)
param_init.normal_init(linear.weight, loc=0.0, scale=1.0)
```

### Kaiming Normal Initialization
> kaiming_normal_init(param, **kwargs):
### [kaiming_normal_init](../../../paddleseg/cvlibs/param_init.py)
```python
kaiming_normal_init(param, **kwargs):
```

Initialize the input tensor with Kaiming Normal initialization.
> Initialize the input tensor with Kaiming Normal initialization.
This function implements the `param` initialization from the paper
> This function implements the `param` initialization from the paper
`Delving Deep into Rectifiers: Surpassing Human-Level Performance on
ImageNet Classification <https://arxiv.org/abs/1502.01852>`
by Kaiming He, Xiangyu Zhang, Shaoqing Ren and Jian Sun. This is a
robust initialization method that particularly considers the rectifier
nonlinearities. In case of Uniform distribution, the range is [-x, x], where
.. math::
x = \sqrt{\\frac{6.0}{fan\_in}}
In case of Normal distribution, the mean is 0 and the standard deviation
nonlinearities.
> In case of Uniform distribution, the range is [-x, x], where
<a href="https://www.codecogs.com/eqnedit.php?latex=x&space;=&space;\sqrt{\frac{6.0}{fan_in}}" target="_blank"><img src="https://latex.codecogs.com/gif.latex?x&space;=&space;\sqrt{\frac{6.0}{fan_in}}" title="x = \sqrt{\frac{6.0}{fan_in}}" /></a>
> In case of Normal distribution, the mean is 0 and the standard deviation
is
.. math::
\sqrt{\\frac{2.0}{fan\_in}}
<a href="https://www.codecogs.com/eqnedit.php?latex=\sqrt{\frac{2.0}{fan_in}}" target="_blank"><img src="https://latex.codecogs.com/gif.latex?\sqrt{\frac{2.0}{fan_in}}" title="\sqrt{\frac{2.0}{fan_in}}" /></a>

> > Args
> > > - **param** (Tensor): Tensor that needs to be initialized.
### Args
* **param** (Tensor): Tensor that needs to be initialized.

> > Examples
### Examples

```python
from paddleseg.cvlibs import param_init
Expand All @@ -134,34 +140,36 @@ linear = nn.Linear(2, 4)
param_init.kaiming_normal_init(linear.weight)
```

## [Config](../../paddleseg/cvlibs/config.py)
> CLASS Config(path, learning_rate, batch_size, iters)
Training configuration parsing. The only yaml/yml file is supported.

The following hyper-parameters are available in the config file:
batch_size: The number of samples per gpu.
iters: The total training steps.
train_dataset: A training data config including type/data_root/transforms/mode.
For data type, please refer to paddleseg.datasets.
For specific transforms, please refer to paddleseg.transforms.transforms.
val_dataset: A validation data config including type/data_root/transforms/mode.
optimizer: A optimizer config, but currently PaddleSeg only supports sgd with momentum in config file.
In addition, weight_decay could be set as a regularization.
learning_rate: A learning rate config. If decay is configured, learning _rate value is the starting learning rate,
where only poly decay is supported using the config file. In addition, decay power and end_lr are tuned experimentally.
loss: A loss config. Multi-loss config is available. The loss type order is consistent with the seg model outputs,
where the coef term indicates the weight of corresponding loss. Note that the number of coef must be the same as the number of
model outputs, and there could be only one loss type if using the same loss type among the outputs, otherwise the number of
loss type must be consistent with coef.
model: A model config including type/backbone and model-dependent arguments.
For model type, please refer to paddleseg.models.
For backbone, please refer to paddleseg.models.backbones.

> > Args
> > > - **path** (str) : The path of config file, supports yaml format only.
> > Examples
## [Config](../../../paddleseg/cvlibs/config.py)
```python
class Config(
path,
learning_rate,
batch_size,
iters
)
```
* Training configuration parsing. The only yaml/yml file is supported.

* The following hyper-parameters are available in the config file:
> **batch_size**: The number of samples per gpu.
> **iters**: The total training steps.
> **train_dataset**: A training data config including type/data_root/transforms/mode.For data type, please refer to paddleseg.datasets.For specific transforms, please refer to paddleseg.transforms.transforms.

> **val_dataset**: A validation data config including type/data_root/transforms/mode.

> **optimizer**: A optimizer config, but currently PaddleSeg only supports sgd with momentum in config file.In addition, weight_decay could be set as a regularization.

> **learning_rate**: A learning rate config. If decay is configured, learning _rate value is the starting learning rate,where only poly decay is supported using the config file. In addition, decay power and end_lr are tuned experimentally.

> **loss**: A loss config. Multi-loss config is available. The loss type order is consistent with the seg model outputs,where the coef term indicates the weight of corresponding loss. Note that the number of coef must be the same as the number of model outputs, and there could be only one loss type if using the same loss type among the outputs, otherwise the number of loss type must be consistent with coef.

> **model**: A model config including type/backbone and model-dependent arguments.For model type, please refer to paddleseg.models.For backbone, please refer to paddleseg.models.backbones.

### Args
* **path** (str) : The path of config file, supports yaml format only.

### Examples

```python
from paddleseg.cvlibs.config import Config
Expand Down
Loading

0 comments on commit 5b50bf0

Please sign in to comment.