Skip to content

Commit

Permalink
add tests softmax
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvanerp committed Aug 27, 2024
1 parent ef7decf commit 987b420
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/layers/softmax_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@testitem "Softmax" begin

using UnboundedBNN: Softmax
using StatsFuns: softmax

A = randn(100, 200)
layer = Softmax(200)
@test all(exp.(layer(A)) .≈ softmax(A, dims = 1))

@test sum(exp, layer(randn(1000))) 1.0
@test sum(exp, layer(randn(1000, 100))) 100.0

@test all(layer(A, zeros(size(A)))[1] .≈ layer(A))
@test layer(A, zeros(size(A)))[2] === nothing

end

0 comments on commit 987b420

Please sign in to comment.