Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature add regularizer base class #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
docs: add regularizer documentation
WuZhuoran committed Jul 11, 2019
commit 2190cdecc8f40eecdd9331bb620aa6deac54f21b
34 changes: 34 additions & 0 deletions neural_nets/regularizers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Usage of regularizers

Regularizers allow to apply penalties on layer parameters or layer activity during optimization. These penalties are incorporated in the loss function that the network optimizes.

The penalties are applied on a per-layer basis.

## Example

```python
from neural_nets import regularizers

```

## Available penalties

```python
regularizers.l1(0.)
regularizers.l2(0.)
regularizers.l1_l2(l1=0.01, l2=0.01)
```

## Developing new regularizers

Any function that takes in a weight matrix and returns a loss contribution tensor can be used as a regularizer, e.g.:

```python
import numpy as np

def l1_reg(weight_matrix):
return 0.01 * np.sum(np.abs(weight_matrix))
```

Alternatively, you can write your regularizers in an object-oriented way;
see the [neural_nets/regularizers.py](regularizers.py) module for examples.