diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f796a66d7..353819673 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -9,6 +9,12 @@ on: - master tags: '*' +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + jobs: test: name: ${{ matrix.suite }} - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} @@ -93,3 +99,29 @@ jobs: - uses: codecov/codecov-action@v2 with: file: lcov.info + + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: '1.6' + - run: | + julia --project=docs -e ' + using Pkg + Pkg.develop(PackageSpec(path=pwd())) + Pkg.instantiate()' + - run: | + julia --color=yes --project=docs/ -e ' + using Metalhead + # using Pkg; Pkg.activate("docs") + using Documenter + using Documenter: doctest + DocMeta.setdocmeta!(Metalhead, :DocTestSetup, :(using Metalhead); recursive=true) + doctest(Metalhead)' + - run: julia --project=docs docs/make.jl + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml deleted file mode 100644 index 5d59ed275..000000000 --- a/.github/workflows/Publish.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Adapted from https://github.com/MichaelHatherly/Publish.jl -name: Publish - -on: - push: - branches: 'master' - -jobs: - publish: - name: "Publish Documentation (dev)" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/checkout@v2 - with: - ref: gh-pages - path: gh-pages - - uses: julia-actions/setup-julia@latest - with: - version: '1' - - name: Install dependencies - run: | - julia --color=yes --project=. -e 'using Pkg; Pkg.instantiate()' - - name: Build and deploy - run: | - cd gh-pages - julia --color=yes --project=../docs -e "using Pkg; Pkg.instantiate()" - julia --color=yes --project=../docs -e 'include("../docs/make.jl"); build_and_deploy("dev")' - git config user.name github-actions - git config user.email github-actions@github.com - git add . - git commit -m "(dev) Built by Publish.jl." - git push diff --git a/.github/workflows/PublishStable.yml b/.github/workflows/PublishStable.yml deleted file mode 100644 index d18b27482..000000000 --- a/.github/workflows/PublishStable.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: PublishStable - -on: - push: - tags: - - '*' - -jobs: - publish: - name: "Publish Documentation (stable)" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/checkout@v2 - with: - ref: gh-pages - path: gh-pages - - uses: julia-actions/setup-julia@latest - with: - version: '1.6' - - name: Install dependencies - run: julia --color=yes --project=. -e 'using Pkg; Pkg.instantiate()' - - name: Build and deploy - run: | - cd gh-pages - julia --color=yes --project=../docs -e "using Pkg; Pkg.instantiate()" - julia --color=yes --project=../docs -e 'include("../docs/make.jl"); build_and_deploy("stable")' - git config user.name github-actions - git config user.email github-actions@github.com - git add . - git commit -m "(stable) Built by Publish.jl." - git push diff --git a/.github/workflows/clean_preview.yml b/.github/workflows/clean_preview.yml new file mode 100644 index 000000000..25946efc3 --- /dev/null +++ b/.github/workflows/clean_preview.yml @@ -0,0 +1,27 @@ +# from https://github.com/CliMA/ClimaTimeSteppers.jl +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 }} diff --git a/.github/workflows/pr_comment.yml b/.github/workflows/pr_comment.yml new file mode 100644 index 000000000..0106e9029 --- /dev/null +++ b/.github/workflows/pr_comment.yml @@ -0,0 +1,14 @@ +name: pr_comment +on: + pull_request: + types: [labeled] +jobs: + pr_comment: + runs-on: ubuntu-latest + steps: + - name: Create PR comment + if: github.event_name == 'pull_request' && github.repository == github.event.pull_request.head.repo.full_name && github.event.label.name == 'documentation' # if this is a pull request build AND the pull request is NOT made from a fork + uses: thollander/actions-comment-pull-request@71efef56b184328c7ef1f213577c3a90edaa4aff + with: + message: 'Once the documentation build has completed, you can preview any updated documentation at this URL: https://fluxml.ai/Metalhead.jl/previews/PR${{ github.event.number }}/' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 487579e25..da77712d1 100644 --- a/README.md +++ b/README.md @@ -9,36 +9,36 @@ ## Installation ```julia -]add Metalhead +julia> ]add Metalhead ``` ## Available models -| Model Name | Function | Pre-trained? | -|:-------------------------------------------------|:------------------------------------------------------------------------------------------|:------------:| -| [VGG](https://arxiv.org/abs/1409.1556) | [`VGG`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.VGG.html) | Y (w/o BN) | -| [ResNet](https://arxiv.org/abs/1512.03385) | [`ResNet`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.ResNet.html) | Y | -| [WideResNet](https://arxiv.org/abs/1605.07146) | [`WideResNet`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.WideResNet.html) | Y | -| [GoogLeNet](https://arxiv.org/abs/1409.4842) | [`GoogLeNet`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.GoogLeNet.html) | N | -| [Inception-v3](https://arxiv.org/abs/1512.00567) | [`Inceptionv3`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.Inceptionv3.html) | N | -| [Inception-v4](https://arxiv.org/abs/1602.07261) | [`Inceptionv4`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.Inceptionv4.html) | N | -| [InceptionResNet-v2](https://arxiv.org/abs/1602.07261) | [`Inceptionv3`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.InceptionResNetv2.html) | N | -| [SqueezeNet](https://arxiv.org/abs/1602.07360) | [`SqueezeNet`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.SqueezeNet.html) | Y | -| [DenseNet](https://arxiv.org/abs/1608.06993) | [`DenseNet`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.DenseNet.html) | N | -| [ResNeXt](https://arxiv.org/abs/1611.05431) | [`ResNeXt`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.ResNeXt.html) | Y | -| [MobileNetv1](https://arxiv.org/abs/1704.04861) | [`MobileNetv1`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.MobileNetv1.html) | N | -| [MobileNetv2](https://arxiv.org/abs/1801.04381) | [`MobileNetv2`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.MobileNetv2.html) | N | -| [MobileNetv3](https://arxiv.org/abs/1905.02244) | [`MobileNetv3`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.MobileNetv3.html) | N | -| [EfficientNet](https://arxiv.org/abs/1905.11946) | [`EfficientNet`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.EfficientNet.html) | N | -| [MLPMixer](https://arxiv.org/pdf/2105.01601) | [`MLPMixer`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.MLPMixer.html) | N | -| [ResMLP](https://arxiv.org/abs/2105.03404) | [`ResMLP`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.ResMLP.html) | N | -| [gMLP](https://arxiv.org/abs/2105.08050) | [`gMLP`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.gMLP.html) | N | -| [ViT](https://arxiv.org/abs/2010.11929) | [`ViT`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.ViT.html) | N | -| [ConvNeXt](https://arxiv.org/abs/2201.03545) | [`ConvNeXt`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.ConvNeXt.html) | N | -| [ConvMixer](https://arxiv.org/abs/2201.09792) | [`ConvMixer`](https://fluxml.ai/Metalhead.jl/dev/docstrings/Metalhead.ConvMixer.html) | N | - -To contribute new models, see our [contributing docs](https://fluxml.ai/Metalhead.jl/dev/docs/dev-guide/contributing.html). +| Model Name | Function | Pre-trained? | +|:-------------------------------------------------|:-----------------------------------------------------------------------------------------------|:------------:| +| [VGG](https://arxiv.org/abs/1409.1556) | [`VGG`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.VGG) | Y (w/o BN) | +| [ResNet](https://arxiv.org/abs/1512.03385) | [`ResNet`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.ResNet) | Y | +| [WideResNet](https://arxiv.org/abs/1605.07146) | [`WideResNet`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.WideResNet) | Y | +| [GoogLeNet](https://arxiv.org/abs/1409.4842) | [`GoogLeNet`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.GoogLeNet) | N | +| [Inception-v3](https://arxiv.org/abs/1512.00567) | [`Inceptionv3`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.Inceptionv3) | N | +| [Inception-v4](https://arxiv.org/abs/1602.07261) | [`Inceptionv4`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.Inceptionv4) | N | +| [InceptionResNet-v2](https://arxiv.org/abs/1602.07261) | [`Inceptionv3`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.InceptionResNetv2) | N | +| [SqueezeNet](https://arxiv.org/abs/1602.07360) | [`SqueezeNet`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.SqueezeNet) | Y | +| [DenseNet](https://arxiv.org/abs/1608.06993) | [`DenseNet`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.DenseNet) | N | +| [ResNeXt](https://arxiv.org/abs/1611.05431) | [`ResNeXt`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.ResNeXt) | Y | +| [MobileNetv1](https://arxiv.org/abs/1704.04861) | [`MobileNetv1`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.MobileNetv1) | N | +| [MobileNetv2](https://arxiv.org/abs/1801.04381) | [`MobileNetv2`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.MobileNetv2) | N | +| [MobileNetv3](https://arxiv.org/abs/1905.02244) | [`MobileNetv3`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.MobileNetv3) | N | +| [EfficientNet](https://arxiv.org/abs/1905.11946) | [`EfficientNet`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.EfficientNet) | N | +| [MLPMixer](https://arxiv.org/pdf/2105.01601) | [`MLPMixer`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.MLPMixer) | N | +| [ResMLP](https://arxiv.org/abs/2105.03404) | [`ResMLP`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.ResMLP) | N | +| [gMLP](https://arxiv.org/abs/2105.08050) | [`gMLP`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.gMLP) | N | +| [ViT](https://arxiv.org/abs/2010.11929) | [`ViT`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.ViT) | N | +| [ConvNeXt](https://arxiv.org/abs/2201.03545) | [`ConvNeXt`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.ConvNeXt) | N | +| [ConvMixer](https://arxiv.org/abs/2201.09792) | [`ConvMixer`](https://fluxml.ai/Metalhead.jl/stable/api/reference.html#Metalhead.ConvMixer) | N | + +To contribute new models, see our [contributing docs](https://fluxml.ai/Metalhead.jl/latest/contributing/). ## Getting Started -You can find the Metalhead.jl getting started guide [here](https://fluxml.ai/Metalhead.jl/dev/docs/tutorials/quickstart.html). +You can find the Metalhead.jl getting started guide [here](https://fluxml.ai/Metalhead.jl/latest/tutorials/quickstart/). diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..a303fff20 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,2 @@ +build/ +site/ diff --git a/docs/Project.toml b/docs/Project.toml index e5e6979e1..6335fa0e9 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,6 +1,8 @@ [deps] +Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" DataAugmentation = "88a5189c-e7ff-4f85-ac6b-e6158070f02e" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" -Metalhead = "dbeba491-748d-5e0e-a39e-b530a07fa0cc" -Publish = "f065f642-d108-4f50-8aa5-6749150a895a" +LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" +OneHotArrays = "0b1bfda6-eb8a-41d2-88d8-f5af5cad476f" diff --git a/docs/make.jl b/docs/make.jl index f5d29f7e9..72fb486c9 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,17 +1,26 @@ -using Pkg +using Documenter, Metalhead, Artifacts, LazyArtifacts, Images, OneHotArrays, DataAugmentation, Flux -Pkg.develop(; path = "..") +DocMeta.setdocmeta!(Metalhead, :DocTestSetup, :(using Metalhead); recursive = true) -using Publish -using Artifacts, LazyArtifacts -using Metalhead +makedocs(modules = [Metalhead, Artifacts, LazyArtifacts, Images, OneHotArrays, DataAugmentation, Flux], + sitename = "Metalhead.jl", + doctest = false, + pages = ["Home" => "index.md", + "Tutorials" => [ + "tutorials/quickstart.md", + ], + "Developer guide" => "contributing.md", + "API reference" => [ + "api/reference.md", + ], + ], + format = Documenter.HTML( + canonical = "https://fluxml.ai/Metalhead.jl/stable/", + # analytics = "UA-36890222-9", + assets = ["assets/flux.css"], + prettyurls = get(ENV, "CI", nothing) == "true"), + ) -# override default theme -cp(artifact"flux-theme", "../_flux-theme"; force = true) - -p = Publish.Project(Metalhead) - -function build_and_deploy(label) - rm(label; recursive = true, force = true) - return deploy(Metalhead; root = "/Metalhead.jl", label = label) -end +deploydocs(repo = "github.com/FluxML/Metalhead.jl.git", + target = "build", + push_preview = true) diff --git a/docs/serve.jl b/docs/serve.jl deleted file mode 100644 index bf4a51179..000000000 --- a/docs/serve.jl +++ /dev/null @@ -1,17 +0,0 @@ -using Pkg - -Pkg.develop(; path = "..") - -using Revise -using Publish -using Artifacts, LazyArtifacts - -using Metalhead - -# override default theme -cp(artifact"flux-theme", "../_flux-theme"; force = true) - -p = Publish.Project(Metalhead) - -# serve documentation -serve(Metalhead) diff --git a/docs/src/api/reference.md b/docs/src/api/reference.md new file mode 100644 index 000000000..1699e81fe --- /dev/null +++ b/docs/src/api/reference.md @@ -0,0 +1,17 @@ +# API Reference + +The API reference of `Metalhead.jl`. + +**Note**: This page is still in progress. + +```@autodocs +Modules = [Metalhead] +``` + +```@docs +Metalhead.create_classifier +Metalhead.squeeze_excite +Metalhead.LayerScale +Metalhead.DropBlock +Metalhead.StochasticDepth +``` diff --git a/docs/src/assets/flux.css b/docs/src/assets/flux.css new file mode 100644 index 000000000..541ead5fe --- /dev/null +++ b/docs/src/assets/flux.css @@ -0,0 +1,113 @@ +@import url('https://fonts.googleapis.com/css?family=Lato:400,400i'); + +body { + font-family: Lato, "Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; +} + +nav.toc { + padding-top: 0; + background: rgb(240, 240, 240); + line-height: 2em; + cursor: default; + user-select: none; +} + +h1+h2 { + margin-top: 0; +} + +/* Green banner in ToC */ +nav.toc > h1 { + margin-top: 0; + padding-top: 0.4em; + padding-bottom: 0.5em; + border-bottom: 5px solid white; + box-shadow: 0px -2px 5px rgb(60,60,60); + margin-bottom: 0.5em; + background: rgb(60, 150, 60); + + font-style: italic; + font-weight: normal; + font-size: 50pt; + text-transform: lowercase; + text-shadow: 2px 2px 5px rgba(0,0,0,0.2); + color: white; +} + +/* Reduce ToC font size */ +.toctext { + font-size: 10pt; +} + +/* Fade out non-clickable ToC headers */ +nav.toc ul span.toctext { + color: rgb(180, 180, 180); +} + +nav.toc ul .toctext { + color: rgb(100, 100, 100); +} + +nav.toc ul a.toctext:hover { + color: inherit; + background: rgb(220, 220, 220); + cursor: default; +} + +nav.toc li.current > .toctext { + background: linear-gradient(90deg, rgb(245,245,245) 0%, white 90%); + font-weight: normal; +} + +nav.toc ul.internal li.toplevel { + font-weight: normal; +} + +/* Content */ + +article { max-width: none; } + +article > p, article > ul { + max-width: 45em; +} + +/* Links */ +a, a:visited { color: rgb(0, 120, 0); } +article p a { border-bottom: 1px solid rgb(200, 230, 200); } +a:hover, a:visited:hover { color: rgb(0, 80, 0); } + +/* Article Links */ +article p a { border-bottom: 1px solid rgb(200, 230, 200); } +article p a:hover, article a:visited:hover { color: rgb(0, 120, 0); } +article p a:hover { border-bottom: 1px solid rgb(150, 200, 150); } + +/* Doctstrings */ +article section.docstring { + padding: 0.5em 0; + border-left: none; + border-right: none; + border-bottom: none; +} + +/* Code */ + +article pre, article p > code { + background: rgb(245, 250, 245); +} + +article pre { + border: none; + max-width: none; + padding: 1em; + border-radius: 10px 0px 0px 10px; + margin-left: -1em; + margin-right: -2em; +} + +.hljs-comment { + font-style: italic; +} + +.hljs-number { + color: rgb(0, 150, 150); +} diff --git a/docs/dev-guide/contributing.md b/docs/src/contributing.md similarity index 100% rename from docs/dev-guide/contributing.md rename to docs/src/contributing.md diff --git a/docs/src/index.md b/docs/src/index.md new file mode 100644 index 000000000..920cb8ba0 --- /dev/null +++ b/docs/src/index.md @@ -0,0 +1,44 @@ +```@meta +CurrentModule = Metalhead +``` + +# Metalhead + +[Metalhead.jl](https://github.com/FluxML/Metalhead.jl) provides standard machine learning vision models for use with [Flux.jl](https://fluxml.ai). The architectures in this package make use of pure Flux layers, and they represent the best-practices for creating modules like residual blocks, inception blocks, etc. in Flux. Metalhead also provides some building blocks for more complex models in the Layers module. + +## Installation + +```julia +julia> ]add Metalhead +``` + +## Available models + +| Model Name | Function | Pre-trained? | +|:-------------------------------------------------------|:----------------------------|:------------:| +| [VGG](https://arxiv.org/abs/1409.1556) | [`VGG`](@ref) | Y (w/o BN) | +| [ResNet](https://arxiv.org/abs/1512.03385) | [`ResNet`](@ref) | Y | +| [WideResNet](https://arxiv.org/abs/1605.07146) | [`WideResNet`](@ref) | Y | +| [GoogLeNet](https://arxiv.org/abs/1409.4842) | [`GoogLeNet`](@ref) | N | +| [Inception-v3](https://arxiv.org/abs/1512.00567) | [`Inceptionv3`](@ref) | N | +| [Inception-v4](https://arxiv.org/abs/1602.07261) | [`Inceptionv4`](@ref) | N | +| [InceptionResNet-v2](https://arxiv.org/abs/1602.07261) | [`Inceptionv3`](@ref) | N | +| [SqueezeNet](https://arxiv.org/abs/1602.07360) | [`SqueezeNet`](@ref) | Y | +| [DenseNet](https://arxiv.org/abs/1608.06993) | [`DenseNet`](@ref) | N | +| [ResNeXt](https://arxiv.org/abs/1611.05431) | [`ResNeXt`](@ref) | Y | +| [MobileNetv1](https://arxiv.org/abs/1704.04861) | [`MobileNetv1`](@ref) | N | +| [MobileNetv2](https://arxiv.org/abs/1801.04381) | [`MobileNetv2`](@ref) | N | +| [MobileNetv3](https://arxiv.org/abs/1905.02244) | [`MobileNetv3`](@ref) | N | +| [EfficientNet](https://arxiv.org/abs/1905.11946) | [`EfficientNet`](@ref) | N | +| [MLPMixer](https://arxiv.org/pdf/2105.01601) | [`MLPMixer`](@ref) | N | +| [ResMLP](https://arxiv.org/abs/2105.03404) | [`ResMLP`](@ref) | N | +| [gMLP](https://arxiv.org/abs/2105.08050) | [`gMLP`](@ref) | N | +| [ViT](https://arxiv.org/abs/2010.11929) | [`ViT`](@ref) | N | +| [ConvNeXt](https://arxiv.org/abs/2201.03545) | [`ConvNeXt`](@ref) | N | +| [ConvMixer](https://arxiv.org/abs/2201.09792) | [`ConvMixer`](@ref) | N | + +To contribute new models, see our [contributing docs](@ref Contributing-to-Metalhead.jl). + +## Getting Started + +You can find the Metalhead.jl getting started guide [here](@ref Quickstart). diff --git a/docs/tutorials/quickstart.md b/docs/src/tutorials/quickstart.md similarity index 82% rename from docs/tutorials/quickstart.md rename to docs/src/tutorials/quickstart.md index cfb99eb72..a00854627 100644 --- a/docs/tutorials/quickstart.md +++ b/docs/src/tutorials/quickstart.md @@ -1,12 +1,10 @@ # Quickstart -{cell=quickstart, display=false, output=false, results=false} ```julia using Flux, Metalhead ``` -Using a model from Metalhead is as simple as selecting a model from the table of [available models](@ref). For example, below we use the pre-trained ResNet-18 model. -{cell=quickstart} +Using a model from Metalhead is as simple as selecting a model from the table of [available models](@ref API-Reference). For example, below we use the pre-trained ResNet-18 model. ```julia using Flux, Metalhead @@ -16,7 +14,6 @@ model = ResNet(18; pretrain = true) Now, we can use this model with Flux like any other model. First, let's check the accuracy on a test image from ImageNet. -{cell=quickstart} ```julia using Images @@ -24,9 +21,8 @@ using Images img = Images.load(download("https://cdn.pixabay.com/photo/2015/05/07/11/02/guitar-756326_960_720.jpg")); ``` We'll use the popular [DataAugmentation.jl](https://github.com/lorenzoh/DataAugmentation.jl) library to crop our input image, convert it to a plain array, and normalize the pixels. -{cell=quickstart} ```julia -using DataAugmentation +using DataAugmentation, OneHotArrays DATA_MEAN = (0.485, 0.456, 0.406) DATA_STD = (0.229, 0.224, 0.225) @@ -39,13 +35,13 @@ data = apply(augmentations, Image(img)) |> itemdata # image net labels labels = readlines(download("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt")) -Flux.onecold(model(Flux.unsqueeze(data, 4)), labels) +onecold(model(Flux.unsqueeze(data, 4)), labels) ``` Below, we train it on some randomly generated data. ```julia -using Flux: onehotbatch +using OneHotArrays: onehotbatch batchsize = 1 data = [(rand(Float32, 224, 224, 3, batchsize), onehotbatch(rand(1:1000, batchsize), 1:1000)) diff --git a/src/convnets/alexnet.jl b/src/convnets/alexnet.jl index 51cfbf029..fba6749e4 100644 --- a/src/convnets/alexnet.jl +++ b/src/convnets/alexnet.jl @@ -45,7 +45,7 @@ Create a `AlexNet`. `AlexNet` does not currently support pretrained weights. -See also [`Metalhead.alexnet`](@ref). +See also [`alexnet`](@ref). """ struct AlexNet layers::Any diff --git a/src/convnets/builders/mbconv.jl b/src/convnets/builders/mbconv.jl index 7b68be300..2f2dadfdb 100644 --- a/src/convnets/builders/mbconv.jl +++ b/src/convnets/builders/mbconv.jl @@ -6,7 +6,7 @@ Creates a block builder for `irblockfn` within a given stage. Note that this function is not intended to be called directly, but instead passed to -[`mbconv_stage_builder`](@ref) which will return a builder over all stages. +[`Metalhead.mbconv_stage_builder`](@ref) which will return a builder over all stages. Users wanting to provide a custom inverted residual block type can extend this function by defining `invresbuilder(::typeof(my_block), ...)`. """ diff --git a/src/convnets/convnext.jl b/src/convnets/convnext.jl index 30b314556..a38840d0b 100644 --- a/src/convnets/convnext.jl +++ b/src/convnets/convnext.jl @@ -8,7 +8,7 @@ Creates a single block of ConvNeXt. - `planes`: number of input channels. - `stochastic_depth_prob`: Stochastic depth probability. - - `layerscale_init`: Initial value for [`LayerScale`](@ref) + - `layerscale_init`: Initial value for [`Metalhead.LayerScale`](@ref) """ function convnextblock(planes::Integer, stochastic_depth_prob = 0.0, layerscale_init = 1.0f-6) diff --git a/src/convnets/squeezenet.jl b/src/convnets/squeezenet.jl index 5d63a565d..1e90dd55c 100644 --- a/src/convnets/squeezenet.jl +++ b/src/convnets/squeezenet.jl @@ -63,7 +63,7 @@ Create a SqueezeNet - `inchannels`: number of input channels. - `nclasses`: the number of output classes. -See also [`Metalhead.squeezenet`](@ref). +See also [`squeezenet`](@ref). """ struct SqueezeNet layers::Any diff --git a/src/utilities.jl b/src/utilities.jl index 6f97e81d2..9f54107fd 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -15,8 +15,6 @@ end Convenience function for applying an activation function to the output after summing up the input arrays. Useful as the `connection` argument for the block function in [`resnet`](@ref). - -See also [`reluadd`](@ref). """ addact(activation = relu, xs...) = activation(sum(xs)) @@ -26,8 +24,6 @@ addact(activation = relu, xs...) = activation(sum(xs)) Convenience function for adding input arrays after applying an activation function to them. Useful as the `connection` argument for the block function in [`resnet`](@ref). - -See also [`addrelu`](@ref). """ actadd(activation = relu, xs...) = sum(activation.(x) for x in xs) diff --git a/toc.md b/toc.md deleted file mode 100644 index c2599e837..000000000 --- a/toc.md +++ /dev/null @@ -1,11 +0,0 @@ -[Introduction](README.md) - -# Tutorials - -* [Quickstart](docs/tutorials/quickstart.md) - -# Developer guide - -* [Contributing](docs/dev-guide/contributing.md) - -[API Reference](docstrings.md) \ No newline at end of file