-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from avik-pal/ap/relax
Formatting updates and relax parameter type
- Loading branch information
Showing
36 changed files
with
673 additions
and
545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
style = "sciml" | ||
whitespace_in_kwargs = false | ||
always_use_return = true | ||
margin = 92 | ||
indent = 4 | ||
format_docstrings = true | ||
join_lines_based_on_source = true | ||
separate_kwargs_with_semicolon = true | ||
always_for_in = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
# v0.4 | ||
|
||
## v0.4.5 | ||
|
||
- Allow Arbitrary Parameter Types | ||
|
||
## v0.4.4 | ||
|
||
* Updated to support julia v1.6 (test time dependency issues) | ||
- Updated to support julia v1.6 (test time dependency issues) | ||
|
||
## v0.4.3 | ||
|
||
* Extending Scale to allow for multiple dimension inputs (https://github.com/avik-pal/Lux.jl/pull/40) | ||
- Extending Scale to allow for multiple dimension inputs (https://github.com/avik-pal/Lux.jl/pull/40) | ||
|
||
## v0.4.2 | ||
|
||
* `SelectDim` is no longer type unstable -- Internal storage for the Layer has been changed | ||
* `Dropout` & `VariationalDropout` return `NoOpLayer` if the probability of dropout is `0` | ||
* Code Formatting -- SciMLStyle (https://github.com/avik-pal/Lux.jl/pull/31) | ||
- `SelectDim` is no longer type unstable -- Internal storage for the Layer has been changed | ||
- `Dropout` & `VariationalDropout` return `NoOpLayer` if the probability of dropout is `0` | ||
- Code Formatting -- SciMLStyle (https://github.com/avik-pal/Lux.jl/pull/31) | ||
|
||
## v0.4.1 | ||
|
||
* Fix math rendering in docs | ||
* Add Setfield compat for v1.0 | ||
- Fix math rendering in docs | ||
- Add Setfield compat for v1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Lux" | ||
uuid = "b2108857-7c20-44ae-9111-449ecde12c47" | ||
authors = ["Avik Pal <[email protected]> and contributors"] | ||
version = "0.4.4" | ||
version = "0.4.5" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Contribution Guidelines | ||
|
||
## Adding New Functionality/Layers | ||
|
||
For Style we try to follow [SciMLStyle](https://github.com/SciML/SciMLStyle). The only reason we don't have a badge yet, is we haven't yet updated the package to followed all the guidelines. Here, I am documenting some additional guidelines we enforce: | ||
|
||
### Mutability | ||
|
||
See [SciMLStyle](https://github.com/SciML/SciMLStyle#out-of-place-and-immutability-is-preferred-when-sufficient-performant) for reference. This is strictly enforced, i.e. all layers/functions provided as part of the external API must be pure functions, even if they come with a performance penalty. | ||
|
||
### Branching -- Generated Functions | ||
|
||
Zygote doesn't like branches in code. Like it or not, we are stuck with it for the near future. Even if julia is able to optimize branches away, Zygote will most certainly throw away those optimizations (these can be tested via `Zygote.@code_ir`). | ||
|
||
#### Writing efficient non-branching code to make Zygote happy | ||
|
||
* Rely on `@generated` functions to remove **most** runtime branching. Certain examples: | ||
* Layers behaving differently during training and inference -- we know at compile-time whether a layer is being run in training/inference mode via `istraining(st)`. | ||
* Composite Layers relying on a variable number of internal layers -- Again we know the length of the number of internal layers at compile time. Hence we can manually unroll the loops. See [`Parallel`](@ref), [`Chain`](@ref), etc. | ||
* Pass around `Val` in state. `Flux.jl` sets `training` to be `(:auto, true, false)`. Hence, which branch will be evaluated, will have to be determined at runtime time (*bad*). Instead if we pass `Val(true)`, we will be able to specialize functions directly based on `true`, `false`, etc. ensuring there is no runtime cost for these operations. See [`BatchNorm`](@ref), [`Dropout`](@ref), etc. | ||
|
||
|
||
## Guide to Documentation for Lux.jl | ||
|
||
### Documentation for Layers | ||
|
||
The first line must be indented by 4 spaces and should contain the possible ways to construct the layer. This should be followed up with a description about what the layer does. If mathematical equations are needed to explain what the layer does, go for it. Often times we fuse parameters to make computation faster, this should be reflected in the equations being used, i.e. equations and the internal code must be consistent. (See [`LSTMCell`](@ref), [`GRUCell`](@ref) for some examples) | ||
|
||
!!! note | ||
There is no need to document how the layers are being called since they **must** adhere to `layer(x, ps, st)`. Any deviation from that and the PR will not be accepted. | ||
|
||
Next, we will have certain subsections (though all of them might not be necessary for all layers) | ||
|
||
* **Arguments**: This section should be present unless the layer is constructed without any arguments (See [`NoOpLayer`](@ref)). All the arguments and their explicit constraints must be explained. | ||
* It is recommended to separate out the Keyword Arguments in their own section | ||
* **Inputs**: This section should always be present. List out the requirements `x` needs to satisfy. (don't write about `ps` and `st` since that is expected by default) | ||
* **Returns**: What will the layer return? We know the second element will be a state but is that updated in any form or not? | ||
* **Parameters**: What are the properties of the NamedTuple returned from `initialparameters`? Omit if the layer is parameterless | ||
* **States**: What are the properties of the NamedTuple returned from `initialstates`? Omit if the layer is stateless | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
20 changes: 11 additions & 9 deletions
20
docs/src/design/recurrent.md → docs/src/design/layer_implementation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
!!! warning | ||
These were not written in the form of tutorials but standalone scripts/packages for people to use | ||
|
||
## Packages | ||
|
||
* [Deep Equilibrium Models](https://github.com/SciML/FastDEQ.jl) | ||
|
||
## Scipts | ||
|
||
* [ImageNet Classification using Metalhead.jl Models](https://github.com/avik-pal/Lux.jl/tree/main/examples/ImageNet) | ||
|
||
|
||
## Packages | ||
|
||
See [Ecosystem](introduction/ecosystem.md) for more details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.