Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/dependencies #36

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
37 changes: 29 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@ using Test
using TextAnalysis
using TextModels

println("Running tests:")

include("crf.jl")
include("ner.jl")
include("pos.jl")
include("sentiment.jl")
include("averagePerceptronTagger.jl")
include("ulmfit.jl")
ENV["DATADEPS_ALWAYS_ACCEPT"] = true

tests = [
"crf.jl"
"ner.jl"
"pos.jl"
"sentiment.jl"
"averagePerceptronTagger.jl"
"ulmfit.jl"
]

function run_tests()
for test in tests
@info "Test: $test"
Test.@testset verbose = true "\U1F4C2 $test" begin
include(test)
end
end
end

@static if VERSION >= v"1.7"
Test.@testset verbose = true showtiming = true "All tests" begin
run_tests()
end
else
Test.@testset verbose = true begin
run_tests()
end
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
Loading