Skip to content

Commit

Permalink
Fix function _size_check() (#2472)
Browse files Browse the repository at this point in the history
* Fix function _size_check()

* Apply suggestion to check for d > 0 as well

Co-authored-by: Anton Smirnov <tonysmn97@gmail.com>

---------

Co-authored-by: Anton Smirnov <tonysmn97@gmail.com>
  • Loading branch information
gruberchr and pxl-th committed Jul 31, 2024
1 parent 804f73b commit 942c6e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/layers/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ Dense(W::LinearAlgebra.Diagonal, bias = true, σ = identity) =
Scale(W.diag, bias, σ)

function _size_check(layer, x::AbstractArray, (d, n)::Pair)
d > 0 || throw(DimensionMismatch(string("layer ", layer,
" expects ndims(input) > ", ndims(x)-d, ", but got ", summary(x))))
0 < d <= ndims(x) || throw(DimensionMismatch(string("layer ", layer,
" expects ndims(input) >= ", d, ", but got ", summary(x))))
size(x, d) == n || throw(DimensionMismatch(string("layer ", layer,
lazy" expects size(input, $d) == $n, but got ", summary(x))))
end
Expand Down

0 comments on commit 942c6e5

Please sign in to comment.