From b4458b455cb5e92dfa2a8a667817f7bf591e2088 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Fri, 5 May 2017 16:07:12 -0400 Subject: [PATCH 1/5] fix broken tests and fix v0.6 deprecations --- REQUIRE | 1 + src/ObjectiveFunctions.jl | 13 +++++++------ test/runtests.jl | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/REQUIRE b/REQUIRE index 0438ee5..0c5ab93 100644 --- a/REQUIRE +++ b/REQUIRE @@ -2,3 +2,4 @@ julia 0.5- Reexport LearnBase +Compat 0.17 # for new type syntax diff --git a/src/ObjectiveFunctions.jl b/src/ObjectiveFunctions.jl index 82979ae..aeb9b66 100644 --- a/src/ObjectiveFunctions.jl +++ b/src/ObjectiveFunctions.jl @@ -2,6 +2,7 @@ __precompile__(true) module ObjectiveFunctions +using Compat: @compat using Reexport @reexport using LearnBase @reexport using LossFunctions @@ -19,7 +20,7 @@ export RegularizedObjective, objective -abstract AbstractLossTransform{T} <: Transformation +@compat abstract type AbstractLossTransform{T} <: Transformation end immutable NoLoss <: AbstractLossTransform{Void} end @@ -41,12 +42,12 @@ immutable LossTransform{T,L<:Loss} <: AbstractLossTransform{T} target::SumNode{T,1} output::OutputNode{T,1} - function LossTransform(loss::Loss, nin::Int) + function (::Type{LossTransform{T, L}}){T, L <: Loss}(loss::Loss, nin::Int) input = InputNode(T, nin) target = InputNode(T, nin) output = OutputNode(T, 1) grad(output)[1] = one(T) # ∂L/∂L == 1 - new(loss, nin, input, target, output) + new{T, L}(loss, nin, input, target, output) end end @@ -54,7 +55,7 @@ LossTransform{L<:Loss}(loss::L, nin::Int) = LossTransform{Float64, L}(loss, nin) # input and target are pre-populated... compute the output value as: ∑ loss(targetᵢ, inputᵢ) function transform!(lt::LossTransform) - lt.output.val[1] = sumvalue(lt.loss, value(lt.target), input_value(lt)) + lt.output.val[1] = value(lt.loss, value(lt.target), input_value(lt), AvgMode.Sum()) lt end @@ -76,12 +77,12 @@ immutable CrossEntropy{T} <: AbstractLossTransform{T} target::SumNode{T,1} output::OutputNode{T,1} - function CrossEntropy(n::Int) + function (::Type{CrossEntropy{T}}){T}(n::Int) input = InputNode(T, n) target = InputNode(T, n) output = OutputNode(T, 1) grad(output)[:] = one(T) # ∂L/∂L == 1 - new(n, input, target, output) + new{T}(n, input, target, output) end end CrossEntropy(n::Int) = CrossEntropy{Float64}(n) diff --git a/test/runtests.jl b/test/runtests.jl index 935f7db..5284992 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,7 +6,7 @@ using Base.Test t = Affine(nin, nout) l = L2DistLoss() λ = 1e-3 - p = L2Penalty(λ) + p = scaled(L2Penalty(), λ) obj = objective(t, l, p) @show obj typeof(obj) From d37c74705a738e818ac7d40ec94993bc1616b9d6 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Fri, 5 May 2017 16:09:05 -0400 Subject: [PATCH 2/5] update travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 29e8de5..7d3be39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,9 @@ language: julia os: - linux - - osx julia: - 0.5 + - 0.6 - nightly notifications: email: false From ed598dc00965c8b30b51e6e2d45c01d2ab2b22b1 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Fri, 5 May 2017 16:12:23 -0400 Subject: [PATCH 3/5] try to fix requirements --- REQUIRE | 3 +++ 1 file changed, 3 insertions(+) diff --git a/REQUIRE b/REQUIRE index 0c5ab93..f672041 100644 --- a/REQUIRE +++ b/REQUIRE @@ -2,4 +2,7 @@ julia 0.5- Reexport LearnBase +LossFunctions +PenaltyFunctions +Transformations Compat 0.17 # for new type syntax From 950797d8f1f6e6ed3dfbf66fa0c5909e5fcdf127 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Fri, 5 May 2017 16:14:20 -0400 Subject: [PATCH 4/5] can't require transformations --- .travis.yml | 7 ++++--- REQUIRE | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d3be39..776bb39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ julia: notifications: email: false # uncomment the following lines to override the default test script -#script: -# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi -# - julia -e 'Pkg.clone(pwd()); Pkg.build("ObjectiveFunctions"); Pkg.test("ObjectiveFunctions"; coverage=true)' +script: + - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi + - julia -e 'Pkg.init(); Pkg.clone("https://github.com/JuliaML/Transformations.jl"); Pkg.build("Transformations")' + - julia -e 'Pkg.clone(pwd()); Pkg.build("ObjectiveFunctions"); Pkg.test("ObjectiveFunctions"; coverage=true)' diff --git a/REQUIRE b/REQUIRE index f672041..91a3dda 100644 --- a/REQUIRE +++ b/REQUIRE @@ -4,5 +4,4 @@ Reexport LearnBase LossFunctions PenaltyFunctions -Transformations Compat 0.17 # for new type syntax From d82c515f84cfaf02a246462ed88ecf064d62951b Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Fri, 5 May 2017 16:16:21 -0400 Subject: [PATCH 5/5] can't use PenaltyFunctions on 0.5 --- .travis.yml | 1 - REQUIRE | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 776bb39..8c6056a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: julia os: - linux julia: - - 0.5 - 0.6 - nightly notifications: diff --git a/REQUIRE b/REQUIRE index 91a3dda..e76f79e 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ -julia 0.5- +julia 0.6- Reexport LearnBase