Skip to content

Commit 964effe

Browse files
remove more deprecations
1 parent df0e449 commit 964effe

File tree

2 files changed

+5
-83
lines changed

2 files changed

+5
-83
lines changed

src/layers/basic.jl

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,10 @@ struct Dense{F, M<:AbstractMatrix, B}
131131
end
132132

133133
function Dense(in::Integer, out::Integer, σ = identity;
134-
initW = nothing, initb = nothing,
135134
init = glorot_uniform, bias=true)
136135

137-
W = if initW !== nothing
138-
Base.depwarn("keyword initW is deprecated, please use init (which similarly accepts a funtion like randn)", :Dense)
139-
initW(out, in)
140-
else
141-
init(out, in)
142-
end
143-
144-
b = if bias === true && initb !== nothing
145-
Base.depwarn("keyword initb is deprecated, please simply supply the bias vector, bias=initb(out)", :Dense)
146-
initb(out)
147-
else
148-
bias
149-
end
150-
136+
W = init(out, in)
137+
b = bias
151138
return Dense(W, b, σ)
152139
end
153140

@@ -186,19 +173,9 @@ struct Diagonal{T}
186173
β::T
187174
end
188175

189-
function Diagonal(sz::Integer...; initα = nothing, initβ = nothing)
190-
α = if initα !== nothing
191-
Base.depwarn("keyword initα is deprecated, please simply supply the desired vectors", :Diagonal)
192-
initα(sz...)
193-
else
194-
ones32(sz...)
195-
end
196-
β = if initβ !== nothing
197-
Base.depwarn("keyword initβ is deprecated, please simply supply the desired vectors", :Diagonal)
198-
initβ(sz...)
199-
else
200-
zeros32(sz...)
201-
end
176+
function Diagonal(sz::Integer...)
177+
α = ones32(sz...)
178+
β = zeros32(sz...)
202179
Diagonal(α, β)
203180
end
204181

src/layers/recurrent.jl

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,6 @@ rnn.state = hidden(rnn.cell)
6666
reset!(m::Recur) = (m.state = m.cell.state0)
6767
reset!(m) = foreach(reset!, functor(m)[1])
6868

69-
70-
# TODO remove in v0.13
71-
function Base.getproperty(m::Recur, sym::Symbol)
72-
if sym === :init
73-
Zygote.ignore() do
74-
@warn "Recur field :init has been deprecated. To access initial state weights, use m::Recur.cell.state0 instead."
75-
end
76-
return getfield(m.cell, :state0)
77-
else
78-
return getfield(m, sym)
79-
end
80-
end
81-
8269
flip(f, xs) = reverse(f.(reverse(xs)))
8370

8471
function (m::Recur)(x::AbstractArray{T, 3}) where T
@@ -175,18 +162,6 @@ julia> r(rand(Float32, 3, 10)) |> size # batch size of 10
175162
RNN(a...; ka...) = Recur(RNNCell(a...; ka...))
176163
Recur(m::RNNCell) = Recur(m, m.state0)
177164

178-
# TODO remove in v0.13
179-
function Base.getproperty(m::RNNCell, sym::Symbol)
180-
if sym === :h
181-
Zygote.ignore() do
182-
@warn "RNNCell field :h has been deprecated. Use m::RNNCell.state0 instead."
183-
end
184-
return getfield(m, :state0)
185-
else
186-
return getfield(m, sym)
187-
end
188-
end
189-
190165
# LSTM
191166

192167
struct LSTMCell{A,V,S}
@@ -259,23 +234,6 @@ julia> l(rand(Float32, 3, 10)) |> size # batch size of 10
259234
LSTM(a...; ka...) = Recur(LSTMCell(a...; ka...))
260235
Recur(m::LSTMCell) = Recur(m, m.state0)
261236

262-
# TODO remove in v0.13
263-
function Base.getproperty(m::LSTMCell, sym::Symbol)
264-
if sym === :h
265-
Zygote.ignore() do
266-
@warn "LSTMCell field :h has been deprecated. Use m::LSTMCell.state0[1] instead."
267-
end
268-
return getfield(m, :state0)[1]
269-
elseif sym === :c
270-
Zygote.ignore() do
271-
@warn "LSTMCell field :c has been deprecated. Use m::LSTMCell.state0[2] instead."
272-
end
273-
return getfield(m, :state0)[2]
274-
else
275-
return getfield(m, sym)
276-
end
277-
end
278-
279237
# GRU
280238

281239
function _gru_output(Wi, Wh, b, x, h)
@@ -348,19 +306,6 @@ julia> g(rand(Float32, 3, 10)) |> size # batch size of 10
348306
GRU(a...; ka...) = Recur(GRUCell(a...; ka...))
349307
Recur(m::GRUCell) = Recur(m, m.state0)
350308

351-
# TODO remove in v0.13
352-
function Base.getproperty(m::GRUCell, sym::Symbol)
353-
if sym === :h
354-
Zygote.ignore() do
355-
@warn "GRUCell field :h has been deprecated. Use m::GRUCell.state0 instead."
356-
end
357-
return getfield(m, :state0)
358-
else
359-
return getfield(m, sym)
360-
end
361-
end
362-
363-
364309
# GRU v3
365310

366311
struct GRUv3Cell{A,V,S}

0 commit comments

Comments
 (0)