Skip to content

Commit

Permalink
dependencies update. Flux >=0.13: reuse Flux.dropout
Browse files Browse the repository at this point in the history
  • Loading branch information
rssdev10 committed Nov 19, 2023
1 parent e620b9b commit 583dddc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
22 changes: 11 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ WordTokenizers = "796a5d58-b03d-544a-977e-18100b691f6e"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
BSON = "0.3.3"
CUDA = "3"
BSON = "0.3"
CUDA = "3, 4, 5"
CorpusLoaders = "0.3"
DataDeps = "0.7"
DataStructures = "0.18.9"
Flux = "0.12.8"
JSON = "0.21.1"
Languages = "0.4.3"
NNlib = "0.7"
StatsBase = "0.33.6"
TextAnalysis = "0.7.3"
WordTokenizers = "0.5.6"
Zygote = "0.6.10"
DataStructures = "0.18"
Flux = "0.13, 0.14"
JSON = "0.21"
Languages = "0.4"
NNlib = "0.7, 0.8, 0.9"
StatsBase = "0.33, 0.34"
TextAnalysis = "0.7, 0.8"
WordTokenizers = "0.5"
Zygote = "0.6"
julia = "1.6"

[extras]
Expand Down
8 changes: 4 additions & 4 deletions src/ULMFiT/custom_layers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This file contains the custom layers defined for this model:
PooledDense
"""

import Flux: gate, testmode!, _dropout_kernel
import Flux: gate, testmode!, dropout

reset_masks!(entity) = nothing
reset_probability!(entity) = nothing
Expand All @@ -25,11 +25,11 @@ It can be used to generate the mask by giving the shape of the desired mask and
function drop_mask(x, p)
y = similar(x, size(x))
Flux.rand!(y)
y .= Flux._dropout_kernel.(y, p, 1 - p)
y .= Flux.dropout(y, p)
return y
end

drop_mask(shape::Tuple, p; type = Float32) = (mask = rand(type, shape...);mask .= _dropout_kernel.(mask, p, 1 - p))
drop_mask(shape::Tuple, p; type = Float32) = (mask = rand(type, shape...);mask .= Flux.dropout(mask, p))

#################### Weight-Dropped LSTM Cell ######################
"""
Expand Down Expand Up @@ -405,5 +405,5 @@ function get_trainable_params(layers)
push!(p, l)
end
end
return params(p...)
return Flux.params(p...)
end
4 changes: 4 additions & 0 deletions test/ulmfit.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Test
using DataDeps
using BSON
using Flux
using Flux: params
using TextModels: ULMFiT

@testset "Custom layers" begin
@testset "WeightDroppedLSTM" begin
Expand Down

0 comments on commit 583dddc

Please sign in to comment.