Skip to content

Commit

Permalink
Merge branch 'master' into activations
Browse files Browse the repository at this point in the history
  • Loading branch information
dsweber2 committed Nov 16, 2019
2 parents 20eb840 + 7eb6a0c commit dea2953
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 39 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ os:
# - osx

julia:
- 1.0
- 1.2
- 1.3
- nightly
Expand Down
59 changes: 21 additions & 38 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,23 @@ git-tree-sha1 = "62847acab40e6855a9b5905ccb99c2b5cf6b3ebb"
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
version = "0.2.0"

[[CSTParser]]
deps = ["Tokenize"]
git-tree-sha1 = "99dda94f5af21a4565dc2b97edf6a95485f116c3"
uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
version = "1.0.0"

[[CUDAapi]]
deps = ["Libdl", "Logging"]
git-tree-sha1 = "e063efb91cfefd7e6afd92c435d01398107a500b"
git-tree-sha1 = "6eee47385c81ed3b3f716b745697869c712c2df3"
uuid = "3895d2a7-ec45-59b8-82bb-cfc6a382f9b3"
version = "1.2.0"
version = "2.0.0"

[[CUDAdrv]]
deps = ["CEnum", "Printf"]
git-tree-sha1 = "96eabc95ebb83e361311330ffb574a3e2df73251"
deps = ["CEnum", "CUDAapi", "Printf"]
git-tree-sha1 = "0f39fddace3324707469ace7fbcbc7b28d5cf921"
uuid = "c5f51814-7f29-56b8-a69c-e4d8f6be1fde"
version = "4.0.2"
version = "4.0.4"

[[CUDAnative]]
deps = ["Adapt", "CEnum", "CUDAapi", "CUDAdrv", "DataStructures", "InteractiveUtils", "LLVM", "Libdl", "Printf", "TimerOutputs"]
git-tree-sha1 = "dd642afe5fd6633663a8c3d42f3b7638f2210b79"
git-tree-sha1 = "93f6c917ab2a9b5bb54f8f738f4ec1a6693cb716"
uuid = "be33ccc6-a3ff-5ff2-a52e-74243cff1e17"
version = "2.5.3"
version = "2.5.5"

[[CodecZlib]]
deps = ["BinaryProvider", "Libdl", "TranscodingStreams"]
Expand Down Expand Up @@ -98,17 +92,11 @@ git-tree-sha1 = "9a11d428dcdc425072af4aea19ab1e8c3e01c032"
uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d"
version = "1.3.0"

[[Crayons]]
deps = ["Test"]
git-tree-sha1 = "f621b8ef51fd2004c7cf157ea47f027fdeac5523"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.0.0"

[[CuArrays]]
deps = ["AbstractFFTs", "Adapt", "CEnum", "CUDAapi", "CUDAdrv", "CUDAnative", "DataStructures", "GPUArrays", "Libdl", "LinearAlgebra", "MacroTools", "NNlib", "Printf", "Random", "Requires", "SparseArrays", "TimerOutputs"]
git-tree-sha1 = "bc94d6cb335d418088f12641751aab63ff56509d"
git-tree-sha1 = "6a05c9e40b99a6e9a7973ca93397a38d3e8a7b4b"
uuid = "3a865a2d-5b23-5a0f-bc46-62713ec82fae"
version = "1.4.2"
version = "1.4.6"

[[DataAPI]]
git-tree-sha1 = "674b67f344687a88310213ddfa8a2b3c76cc4252"
Expand Down Expand Up @@ -164,9 +152,9 @@ version = "0.6.1"

[[ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "NaNMath", "Random", "SpecialFunctions", "StaticArrays"]
git-tree-sha1 = "adf88d6da1f0294058f38295becf8807986bb7d0"
git-tree-sha1 = "4407e7b76999eca2646abdb68203bd4302476168"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.5"
version = "0.10.6"

[[GPUArrays]]
deps = ["AbstractFFTs", "Adapt", "LinearAlgebra", "Printf", "Random", "Serialization"]
Expand Down Expand Up @@ -216,10 +204,10 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[MacroTools]]
deps = ["CSTParser", "Compat", "DataStructures", "Test", "Tokenize"]
git-tree-sha1 = "d6e9dedb8c92c3465575442da456aec15a89ff76"
deps = ["Compat", "DataStructures", "Test"]
git-tree-sha1 = "82921f0e3bde6aebb8e524efc20f4042373c0c06"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.1"
version = "0.5.2"

[[Markdown]]
deps = ["Base64"]
Expand Down Expand Up @@ -327,9 +315,9 @@ version = "0.8.0"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "1e9c5d89cba8047d518f1ffef432906ef1a3e8bd"
git-tree-sha1 = "5a3bcb6233adabde68ebc97be66e95dcb787424c"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "0.12.0"
version = "0.12.1"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
Expand All @@ -346,15 +334,10 @@ deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TimerOutputs]]
deps = ["Crayons", "Printf", "Test", "Unicode"]
git-tree-sha1 = "b80671c06f8f8bae08c55d67b5ce292c5ae2660c"
deps = ["Printf"]
git-tree-sha1 = "8f22dc0c23e1cd4ab8070a01ba32285926f104f1"
uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
version = "0.5.0"

[[Tokenize]]
git-tree-sha1 = "dfcdbbfb2d0370716c815cbd6f8a364efb6f42cf"
uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624"
version = "0.5.6"
version = "0.5.2"

[[TranscodingStreams]]
deps = ["Random", "Test"]
Expand Down Expand Up @@ -389,9 +372,9 @@ version = "0.8.3"

[[Zygote]]
deps = ["DiffRules", "FFTW", "FillArrays", "ForwardDiff", "IRTools", "InteractiveUtils", "LinearAlgebra", "MacroTools", "NNlib", "NaNMath", "Random", "Requires", "SpecialFunctions", "Statistics", "ZygoteRules"]
git-tree-sha1 = "b2e42a21dc3d1ecd3cbe8c83a454ca56fbf423c4"
git-tree-sha1 = "e4245b9c5362346e154b62842a89a18e0210b92b"
uuid = "e88e6eb3-aa80-5325-afca-941959d7151f"
version = "0.4.0"
version = "0.4.1"

[[ZygoteRules]]
deps = ["MacroTools"]
Expand Down
4 changes: 4 additions & 0 deletions src/layers/stateless.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using CuArrays
using NNlib: logsoftmax, logσ

# Cost functions
Expand Down Expand Up @@ -35,6 +36,9 @@ Return `-y*log(ŷ + ϵ) - (1-y)*log(1-ŷ + ϵ)`. The ϵ term provides numerica
"""
binarycrossentropy(ŷ, y; ϵ=eps(ŷ)) = -y*log(ŷ + ϵ) - (1 - y)*log(1 -+ ϵ)

# Re-definition to fix interaction with CuArrays.
CuArrays.@cufunc binarycrossentropy(ŷ, y; ϵ=eps(ŷ)) = -y*log(ŷ + ϵ) - (1 - y)*log(1 -+ ϵ)

"""
logitbinarycrossentropy(logŷ, y)
Expand Down
4 changes: 4 additions & 0 deletions test/cuda/cuda.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ cx = gpu(x)
@test Flux.crossentropy(x,x, weight=1.0) Flux.crossentropy(cx,cx, weight=1.0)
@test Flux.crossentropy(x,x, weight=[1.0;2.0;3.0]) Flux.crossentropy(cx,cx, weight=cu([1.0;2.0;3.0]))

x = σ.([-1.1491, 0.8619, 0.3127])
y = [1, 1, 0.]
@test Flux.binarycrossentropy.(x,y) Flux.binarycrossentropy.(cu(x),cu(y))

xs = rand(5, 5)
ys = Flux.onehotbatch(1:5,1:5)
@test collect(cu(xs) .+ cu(ys)) collect(xs .+ ys)
Expand Down
3 changes: 2 additions & 1 deletion test/layers/normalisation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ end

end

if VERSION >= v"1.1"
@testset "GroupNorm" begin
# begin tests
squeeze(x) = dropdims(x, dims = tuple(findall(size(x) .== 1)...)) # To remove all singular dimensions
Expand Down Expand Up @@ -289,5 +290,5 @@ end
x = Float32.(reshape(collect(1:prod(sizes)), sizes))
@test BN(x) GN(x)
end

end
end

0 comments on commit dea2953

Please sign in to comment.