Skip to content

Commit

Permalink
Merge pull request #266 from FluxML/a2/docs-fix
Browse files Browse the repository at this point in the history
Move to Documenter 1.0 (and some miscellaneous fixes)
  • Loading branch information
theabhirath authored Dec 26, 2023
2 parents b2ec1d6 + 0aff9b8 commit 2ad3337
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 26 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ jobs:
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 }}
Expand Down
4 changes: 4 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
Metalhead = "dbeba491-748d-5e0e-a39e-b530a07fa0cc"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"

[compat]
Documenter = "1"
10 changes: 4 additions & 6 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using Documenter, Metalhead, Artifacts, LazyArtifacts, Images, DataAugmentation, Flux

DocMeta.setdocmeta!(Metalhead, :DocTestSetup, :(using Metalhead); recursive = true)
using Documenter, Metalhead

# copy readme into index.md
open(joinpath(@__DIR__, "src", "index.md"), "w") do io
write(io, read(joinpath(@__DIR__, "..", "README.md"), String))
end

makedocs(; modules = [Metalhead, Artifacts, LazyArtifacts, Images, DataAugmentation, Flux],
makedocs(; modules = [Metalhead],
sitename = "Metalhead.jl",
doctest = false,
pages = ["Home" => "index.md",
"Tutorials" => [
"tutorials/quickstart.md",
Expand Down Expand Up @@ -41,7 +38,8 @@ makedocs(; modules = [Metalhead, Artifacts, LazyArtifacts, Images, DataAugmentat
"Model Utilities" => "api/utilities.md",
],
],
format = Documenter.HTML(; canonical = "https://fluxml.ai/Metalhead.jl/stable/",
warnonly = [:example_block, :missing_docs, :cross_references],
format = Documenter.HTML(canonical = "https://fluxml.ai/Metalhead.jl/stable/",
# analytics = "UA-36890222-9",
assets = ["assets/flux.css"],
prettyurls = get(ENV, "CI", nothing) == "true"))
Expand Down
4 changes: 2 additions & 2 deletions src/Metalhead.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ using Random

import Functors

# Utilities
include("utilities.jl")
# Model utilities
include("core.jl")

# Custom Layers
include("layers/Layers.jl")
include("layers/utilities.jl") # layer utilities
using .Layers

# CNN models
Expand Down
2 changes: 1 addition & 1 deletion src/convnets/builders/resnet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Creates a generic ResNet-like model.
- `block_repeats`: This is a `Vector` of integers that specifies the number of repeats of each
block in each stage.
- `connection`: This is a function that determines the residual connection in the model. For
`resnets`, either of [`Metalhead.addact`](@ref) or [`Metalhead.actadd`](@ref) is recommended.
`resnets`, either of [`Metalhead.Layers.addact`](@ref) or [`Metalhead.Layers.actadd`](@ref) is recommended.
- `classifier_fn`: This is a function that takes in the number of feature maps and returns a
classifier. This is usually built as a closure using a function like [`Metalhead.create_classifier`](@ref).
For example, if the number of output classes is `nclasses`, then the function can be defined as
Expand Down
2 changes: 1 addition & 1 deletion src/convnets/resnets/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ Wide ResNet, ResNeXt and Res2Net. For an _even_ more generic model API, see [`Me
- `inplanes`: The number of input channels in the first convolutional layer.
- `reduction_factor`: The reduction factor used in the model.
- `connection`: This is a function that determines the residual connection in the model. For
`resnets`, either of [`Metalhead.addact`](@ref) or [`Metalhead.actadd`](@ref) is recommended.
`resnets`, either of [`Metalhead.Layers.addact`](@ref) or [`Metalhead.Layers.actadd`](@ref) is recommended.
These decide whether the residual connection is added before or after the activation function.
- `norm_layer`: The normalisation layer to be used in the model.
- `revnorm`: set to `true` to place the normalisation layers before the convolutions
Expand Down
2 changes: 1 addition & 1 deletion src/layers/Layers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using Random

import Flux.testmode!

include("../utilities.jl")
include("utilities.jl")

include("attention.jl")
export MultiHeadSelfAttention
Expand Down
2 changes: 1 addition & 1 deletion src/layers/conv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Create a convolution + normalisation layer pair with activation.
- `pad`: padding of the convolution kernel
- `dilation`: dilation of the convolution kernel
- `groups`: groups for the convolution kernel
- `weight`, `init`: initialization for the convolution kernel (see [`Flux.Conv`](@ref))
- `weight`, `init`: initialization for the convolution kernel (see `Flux.Conv`)
"""
function conv_norm(kernel_size::Dims{2}, inplanes::Integer, outplanes::Integer,
activation = relu; norm_layer = BatchNorm, revnorm::Bool = false,
Expand Down
2 changes: 1 addition & 1 deletion src/layers/mbconv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ See Fig. 3 in [reference](https://arxiv.org/abs/1704.04861v1).
- `bias`: whether to use bias in the convolution layers.
- `stride`: stride of the first convolution kernel
- `pad`: padding of the first convolution kernel
- `weight`, `init`: initialization for the convolution kernel (see [`Flux.Conv`](@ref))
- `weight`, `init`: initialization for the convolution kernel (see `Flux.Conv`)
"""
function dwsep_conv_norm(kernel_size::Dims{2}, inplanes::Integer, outplanes::Integer,
activation = relu; norm_layer = BatchNorm, stride::Integer = 1,
Expand Down
8 changes: 4 additions & 4 deletions src/utilities.jl → src/layers/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ 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 [`Metalhead.resnet`](@ref).
function in `Metalhead.resnet`.
"""
addact(activation = relu, xs...) = activation(sum(xs))

"""
actadd(activation = relu, xs...)
Convenience function for adding input arrays after applying an activation
function to them. Useful as the `connection` argument for the block function in
[`Metalhead.resnet`](@ref).
Convenience function for summing up the input arrays after applying an
activation function to them. Useful as the `connection` argument for the block
function in `Metalhead.resnet`.
"""
actadd(activation = relu, xs...) = sum(activation.(x) for x in xs)

Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

[compat]
CUDA = "4, 5"
Expand Down
5 changes: 4 additions & 1 deletion test/model_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Metalhead, Images, TestImages
using Flux: gradient, gpu
using CUDA: CUDA, has_cuda
using Downloads

export PRETRAINED_MODELS,
TEST_FAST,
Expand Down Expand Up @@ -72,7 +73,9 @@ const TEST_X = let img_array = convert(Array{Float32}, channelview(TEST_IMG))
end

# ImageNet labels
const TEST_LBLS = readlines(download("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt"))
const TEST_LBLS = readlines(Downloads.download(
"https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt"
))

function acctest(model)
ypred = gpu(model)(TEST_X) |> collect |> vec
Expand Down

2 comments on commit 2ad3337

@theabhirath
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/97834

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.1 -m "<description of version>" 2ad3337e42a8df03a411f2c38b83028c68cb8286
git push origin v0.9.1

Please sign in to comment.