Skip to content

Commit 6405ab3

Browse files
authored
upgrade warnings (#1926)
1 parent d317492 commit 6405ab3

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/deprecations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# v0.12 deprecations
22

33
function ones(dims...)
4-
Base.depwarn("Flux.ones(size...) is deprecated, please use Flux.ones32(size...) or Base.ones(Float32, size...)", :ones)
4+
Base.depwarn("Flux.ones(size...) is deprecated, please use Flux.ones32(size...) or Base.ones(Float32, size...)", :ones, force=true)
55
Base.ones(Float32, dims...)
66
end
77
ones(T::Type, dims...) = Base.ones(T, dims...)
88

99
function zeros(dims...)
10-
Base.depwarn("Flux.zeros(size...) is deprecated, please use Flux.zeros32(size...) or Base.zeros(Float32, size...)", :zeros)
10+
Base.depwarn("Flux.zeros(size...) is deprecated, please use Flux.zeros32(size...) or Base.zeros(Float32, size...)", :zeros, force=true)
1111
Base.zeros(Float32, dims...)
1212
end
1313
zeros(T::Type, dims...) = Base.zeros(T, dims...)

src/losses/utils.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ end
2626
ChainRulesCore.@scalar_rule xlogy(x, y) (log(y), x/y) # should help Diffractor's broadcasting
2727
ChainRulesCore.@scalar_rule xlogx(x) (log(y) + true)
2828

29-
# This can be made an error in Flux v0.13, for now just a warning
3029
function _check_sizes(ŷ::AbstractArray, y::AbstractArray)
3130
for d in 1:max(ndims(ŷ), ndims(y))
32-
if size(ŷ,d) != size(y,d)
33-
@warn "Size mismatch in loss function! In future this will be an error. In Flux <= 0.12 broadcasting accepts this, but may not give sensible results" summary(ŷ) summary(y) maxlog=3 _id=hash(size(y))
34-
end
31+
size(ŷ,d) == size(y,d) || throw(DimensionMismatch(
32+
"loss function expects size(ŷ) = $(size(ŷ)) to match size(y) = $(size(y))"
33+
))
3534
end
3635
end
3736
_check_sizes(ŷ, y) = nothing # pass-through, for constant label e.g. y = 1

0 commit comments

Comments
 (0)