-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
914 additions
and
55 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Doc Preview Cleanup | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
doc-preview-cleanup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout gh-pages branch | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: gh-pages | ||
- name: Delete preview and history + push changes | ||
run: | | ||
if [ -d "previews/PR$PRNUM" ]; then | ||
git config user.name "Documenter.jl" | ||
git config user.email "documenter@juliadocs.github.io" | ||
git rm -rf "previews/PR$PRNUM" | ||
git commit -m "delete preview" | ||
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree}) | ||
git push --force origin gh-pages-new:gh-pages | ||
fi | ||
env: | ||
PRNUM: ${{ github.event.number }} |
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,27 @@ | ||
name: Documentation | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # update to match your development branch (master, main, dev, trunk, ...) | ||
- dev | ||
tags: '*' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: '1.9' | ||
- name: Install dependencies | ||
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(;verbose=true)' | ||
- name: Build and deploy | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token | ||
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key | ||
run: julia --project=docs/ docs/make.jl |
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,15 @@ | ||
name: TagBot | ||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
workflow_dispatch: | ||
jobs: | ||
TagBot: | ||
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: JuliaRegistries/TagBot@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
ssh: ${{ secrets.DOCUMENTER_KEY }} |
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 |
---|---|---|
|
@@ -9,4 +9,6 @@ Manifest.toml | |
*.png | ||
|
||
/docs/build/ | ||
/docs/site/ | ||
/docs/site/ | ||
|
||
*.ipynb |
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,6 @@ | ||
QuantizedNetworks.jl | ||
--- | ||
|
||
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://ctuavastlab.github.io/QuantizedNetworks.jl/stable) | ||
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://ctuavastlab.github.io/QuantizedNetworks.jl/dev) | ||
|
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,54 @@ | ||
# Blocks | ||
|
||
## DenseBlock | ||
```@docs | ||
DenseBlock | ||
``` | ||
### Standard Dense Layer | ||
```@docs | ||
QuantizedNetworks.Flux.Dense(l::DenseBlock) | ||
``` | ||
|
||
### Examples | ||
```jldoctest | ||
julia> using Random, QuantizedNetworks; Random.seed!(3); | ||
julia> db = DenseBlock(2=>2) | ||
DenseBlock(Chain(QuantizedDense(2 => 2; bias=false, quantizer=Ternary(0.05, STE(2))), BatchNorm(2), Sign(STE(2)))) | ||
julia> x = rand(Float32, 2, 4) | ||
2×4 Matrix{Float32}: | ||
0.940675 0.100403 0.789168 0.582228 | ||
0.999979 0.0921143 0.698426 0.496285 | ||
julia> db(x) | ||
2×4 Matrix{Float32}: | ||
-1.0 1.0 1.0 1.0 | ||
1.0 -1.0 -1.0 -1.0 | ||
``` | ||
|
||
|
||
## FeatureBlock | ||
```@docs | ||
FeatureBlock | ||
``` | ||
|
||
### Examples | ||
```jldoctest | ||
julia> using Random, QuantizedNetworks; Random.seed!(3); | ||
julia> fb = FeatureBlock(2, 2) | ||
FeatureBlock(Parallel(vcat, FeatureQuantizer(2 => 4; quantizer=Sign(STE(2))))) | ||
julia> x = rand(Float32, 2, 1) | ||
2×1 Matrix{Float32}: | ||
0.8521847 | ||
0.7965402 | ||
julia> fb(x) | ||
4×1 Matrix{Float32}: | ||
1.0 | ||
1.0 | ||
1.0 | ||
-1.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Estimators | ||
```@docs | ||
QuantizedNetworks.AbstractEstimator | ||
``` | ||
|
||
## Straight through estimators | ||
```@docs | ||
QuantizedNetworks.STE | ||
QuantizedNetworks.PolynomialSTE | ||
QuantizedNetworks.SwishSTE | ||
QuantizedNetworks.StochasticSTE | ||
``` |
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,21 @@ | ||
# L0 gate | ||
|
||
```@docs | ||
L0Gate | ||
``` | ||
|
||
### Functions | ||
|
||
```@docs | ||
QuantizedNetworks.isactive(c::L0Gate) | ||
QuantizedNetworks.Flux.testmode!(c::L0Gate, mode=true) | ||
``` | ||
|
||
### Helper functions | ||
```@docs | ||
QuantizedNetworks._shape(s, ::Colon) | ||
QuantizedNetworks._shape(s, dims) | ||
QuantizedNetworks.shift(x::T, lo::Real = -0.1, hi::Real = 1.1) where {T} | ||
QuantizedNetworks.l0gate_train(x::AbstractArray{T}, logα, β; dims = :) where {T} | ||
QuantizedNetworks.l0gate_test(::AbstractArray{T}, logα, β) where {T} | ||
``` |
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,8 +1,65 @@ | ||
# Layers and Blocks | ||
# Layers | ||
|
||
## QuantDense | ||
```@docs | ||
QuantizedNetworks.QuantizedDense | ||
QuantizedNetworks.DenseBlock | ||
QuantizedNetworks.FeatureQuantizer | ||
QuantizedNetworks.FeatureBlock | ||
QuantDense | ||
``` | ||
### Logic | ||
```@docs | ||
QuantizedNetworks.nn2logic(layer::QuantDense) | ||
``` | ||
|
||
### Examples | ||
|
||
```jldoctest | ||
julia> using Random, QuantizedNetworks; Random.seed!(3); | ||
julia> x = rand(Float32, 1, 2); | ||
julia> qd = QuantDense(1 => 2) | ||
QuantDense(1 => 2, identity; weight_lims=(-1.0f0, 1.0f0), bias=false, Ternary(0.05, STE(2)), Sign(STE(2))) | ||
julia> qd(x) | ||
2×2 Matrix{Float32}: | ||
-1.0 -1.0 | ||
1.0 1.0 | ||
julia> d = QuantizedNetworks.nn2logic(qd) | ||
Dense(1 => 2, Sign(STE(2))) # 4 parameters | ||
julia> d([3]) | ||
2-element Vector{Float32}: | ||
-1.0 | ||
1.0 | ||
``` | ||
|
||
## FeatureQuantizer | ||
```@docs | ||
FeatureQuantizer | ||
``` | ||
|
||
### Forward pass | ||
```@docs | ||
QuantizedNetworks._forward_pass(w, b, x) | ||
``` | ||
|
||
### Backpropagation | ||
```@docs | ||
QuantizedNetworks.ChainRulesCore.rrule(::typeof(QuantizedNetworks._forward_pass), w, b, x) | ||
``` | ||
|
||
### Examples | ||
```jldoctest | ||
julia> using Random, QuantizedNetworks; Random.seed!(3); | ||
julia> x = Float32.([1 2 ;3 4]); | ||
julia> fq = FeatureQuantizer(2,2); | ||
julia> fq(x) | ||
4×2 Matrix{Float32}: | ||
1.0 1.0 | ||
1.0 -1.0 | ||
-1.0 -1.0 | ||
1.0 1.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Optimizers | ||
|
||
# Bop | ||
```@docs | ||
Bop | ||
QuantizedNetworks.Flux.Optimise.apply!(b::Bop, x, Δ) | ||
``` | ||
|
||
# Case optimizer | ||
```@docs | ||
CaseOptimizer | ||
QuantizedNetworks.Flux.Optimise.apply!(o::CaseOptimizer, x, Δ) | ||
``` | ||
|
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,17 +1,23 @@ | ||
# Quantizers and Estimators | ||
## Estimators | ||
# Quantizers | ||
```@docs | ||
QuantizedNetworks.AbstractEstimator | ||
QuantizedNetworks.STE | ||
QuantizedNetworks.PolynomialSTE | ||
QuantizedNetworks.SwishSTE | ||
QuantizedNetworks.StochasticSTE | ||
QuantizedNetworks.AbstractQuantizer | ||
QuantizedNetworks.forward_pass(q::AbstractQuantizer, x) | ||
QuantizedNetworks.pullback(q::AbstractQuantizer, x) | ||
``` | ||
|
||
## Quantizers | ||
## Binary | ||
```@docs | ||
QuantizedNetworks.AbstractQuantizer | ||
QuantizedNetworks.Sign | ||
QuantizedNetworks.Heaviside | ||
``` | ||
|
||
## Ternary | ||
```@docs | ||
QuantizedNetworks.Ternary | ||
``` | ||
``` | ||
|
||
## References | ||
|
||
- [`Binarized Neural Networks: Training Deep Neural Networks with Weights and Activations Constrained to +1 or -1`](https://arxiv.org/abs/1602.02830) | ||
- [`Bi-Real Net: Enhancing the Performance of 1-bit CNNs With Improved Representational Capability and Advanced Training Algorithm`](https://arxiv.org/abs/1808.00278) | ||
- [`Regularized Binary Network Training`](https://arxiv.org/abs/1812.11800) |
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,5 +1,6 @@ | ||
# Utilities | ||
|
||
## ClippedArray | ||
```@docs | ||
QuantizedNetworks.ClippedArray | ||
``` |
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 @@ | ||
# Flower Example |
Oops, something went wrong.