Skip to content

Commit

Permalink
add contributing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
cgarciae committed Jul 23, 2020
1 parent 7ea8749 commit 97d9d9a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
54 changes: 54 additions & 0 deletions docs/guides/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Contributing
This is a shot guide on how to start contibuting to Elegy along with some best practices for the project.

## Setup
We use `poetry` so the easiest way to setup a development environment is run

```bash
poetry install
```

## Creating Losses and Metrics
For this you can follow these guidelines:

* Each loss / metric should be defined in its own file.
* Inherit from either `elegy.losses.loss.Loss` or `elegy.metrics.metric.Metric` or an existing class that inherits from them.
* Try to use an existing metric or loss as a template
* You must provide documentation for the following:
* The class definition.
* The `__init__` method.
* The `call` method.
* Try to port the documentation + signature from its Keras counter part.
* If so you must give credits to the original source file.
* You must include tests.
* If you there exists an equivalent loss/metric in Keras you must test numerical equivalence between both.

## Testing
To execute all the tests just run
```bash
pytest
```

## Documentation
We use `mkdocs`. If you create a new object that requires documentation please do the following:

* Add a markdown file inside `/docs/api` in the appropriate location according to the project's structure. This file must:
* Contain the path of function / class as header
* Use `mkdocstring` to render the API information.
* Example:
```markdown
# elegy.losses.BinaryCrossentropy

::: elegy.losses.BinaryCrossentropy
selection:
inherited_members: true
members:
- call
- __init__
```
* Add and entry to `mkdocs.yml` inside `nav` pointing to this file. Checkout `mkdocs.yml`.

To build and visualize the documentation locally run
```bash
mkdocs serve
```
5 changes: 4 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Install Elegy using pip:
pip install elegy
```

For Windows users we recomend the Windows subsystem for linux 2 [WSL2](https://docs.microsoft.com/es-es/windows/wsl/install-win10?redirectedfrom=MSDN) since [jax](https://github.com/google/jax/issues/438) does not have support for it yet.

## Quick Start
Elegy greatly simplifies the training of Deep Learning models compared to pure Jax / Haiku where, due to Jax functional nature, users have to do a lot of book keeping around the state of the model. In Elegy just you just have to follow 3 basic steps:

Expand All @@ -39,7 +41,7 @@ class MLP(elegy.Module):
])
return mlp(image)
```
**2.** Create a `Model` from this module and specify additional things like losses, metrics, optimizers, and callbacks:
**2.** Create a `Model` from this module and specify additional things like losses, metrics, and optimizers:
```python
model = elegy.Model(
module=MLP.defer(),
Expand All @@ -61,6 +63,7 @@ model.fit(
batch_size=64,
validation_data=(X_test, y_test),
shuffle=True,
callbacks=[elegy.callbacks.TensorBoard("summaries")]
)
```

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ nav:
- Getting Started: getting-started.ipynb
- Guides:
Modules, Losses, and Metrics: guides/modules-losses-metrics.md
Contibuting: guides/contributing.md
- API Reference:
Model: api/Model.md
# Module: api/Module.md
Expand Down

0 comments on commit 97d9d9a

Please sign in to comment.