Skip to content

Commit

Permalink
fixes for julia 0.5-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
vilen committed Dec 2, 2015
1 parent e7be58d commit 62f1766
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/algorithms/adaptive_l1rda_alg.jl
Expand Up @@ -64,9 +64,9 @@ function adaptive_l1rda_alg(dfunc::Function, X, Y, λ::Float64, γ::Float64, ρ:
# do not perform sparse(...) and filter and map over SparceMatrixCSC
# because Garbage Collection performs realy badly in the tight loops
h = t>1 ? h + g_new.^2 : sparse+g_new.^2)
h_sq = SparseVector(d,h.rowval,-(t*γ)./sqrt(h.nzval))
gs = SparseVector(d,g.rowval,sign(g.nzval))
w = h_sq.*(sparsevec(g) .- λ.*gs); ind = abs(g.nzval).>λ
h_sq = SparseMatrixCSC(d,1,h.colptr,h.rowval,-(t*γ)./sqrt(h.nzval))
gs = SparseMatrixCSC(d,1,g.colptr,g.rowval,sign(g.nzval))
w = h_sq.*(g - λ.*gs); ind = abs(g.nzval) .> λ
w = isempty(ind) ? w_prev : reduce_sparsevec(w,find(ind))
end

Expand Down
3 changes: 1 addition & 2 deletions src/algorithms/dropout_alg.jl
Expand Up @@ -55,9 +55,8 @@ function dropout_alg(dfunc::Function, X, Y, λ::Float64, k::Int, max_iter::Int,
dropout = map(rand, prob)
else
bern_vars = map(f_sample,w.nzval)
dropout = SparseVector(d,w.nzind,bern_vars)
dropout = SparseMatrixCSC(d,1,w.colptr,w.rowval,bern_vars)
dropout = reduce_sparsevec(dropout,find(bern_vars))
grad = sparsevec(grad)
end

# do a gradient descent step
Expand Down
8 changes: 4 additions & 4 deletions src/loss_derivative.jl
Expand Up @@ -16,10 +16,10 @@
#

# Solution evaluation at sample(s) At with or w/o labels yt
evaluate(At::SparseMatrixCSC,yt,w) = map(i->sum(At[:,i].*w),1:1:length(yt)).*yt
evaluate(At::SparseMatrixCSC,w) = map(i->sum(At[:,i].*w),1:1:size(At,2))
evaluate(At::SparseVector,yt,w) = sum(At.*w).*yt
evaluate(At::SparseVector,w) = sum(At.*w)
evaluate(At::AbstractSparseMatrix,yt,w) = map(i->sum(At[:,i].*w),1:1:length(yt)).*yt
evaluate(At::AbstractSparseMatrix,w) = map(i->sum(At[:,i].*w),1:1:size(At,2))
evaluate(At::AbstractSparseVector,yt,w) = sum(At.*w).*yt
evaluate(At::AbstractSparseVector,w) = sum(At.*w)
evaluate(At::Matrix,yt,w) = map(i->sum(At[:,i].*w),1:1:length(yt)).*yt
evaluate(At::Matrix,w) = map(i->sum(At[:,i].*w),1:1:size(At,2))
evaluate(At::Vector,yt,w) = dot(At,w[:])*yt
Expand Down

0 comments on commit 62f1766

Please sign in to comment.