You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE Because svm_model contains pointers to svm_problem, you can
not free the memory used by svm_problem if you are still using the
svm_model produced by svm_train().
This causes LIBSVM package to randomly fail if julia garbage-collects the SVMProblem and nodes before calling svmpredict.
This patch solves the isue:
diff --git a/src/LIBSVM.jl b/src/LIBSVM.jl
index f50b760..b1d72e5 100644
--- a/src/LIBSVM.jl
+++ b/src/LIBSVM.jl
@@ -66,6 +66,9 @@ end
type SVMModel{T}
ptr::Ptr{Void}
param::Vector{SVMParameter}
+ problem::Vector{SVMProblem}
+ nodes::Array{SVMNode,2}
+ nodeptr::Vector{Ptr{SVMNode}}
labels::Vector{T}
weight_labels::Vector{Int32}
weights::Vector{Float64}
@@ -224,7 +227,7 @@ function svmtrain{T, U<:Real}(labels::AbstractVector{T},
ptr = ccall(svm_train(), Ptr{Void}, (Ptr{SVMProblem},
Ptr{SVMParameter}), problem, param)
- model = SVMModel(ptr, param, reverse_labels, weight_labels, weights,
+ model = SVMModel(ptr, param, problem, nodes, nodeptrs, reverse_labels, weight_labels, weights,
size(instances, 1), verbose)
finalizer(model, svmfree)
model
The text was updated successfully, but these errors were encountered:
From libsvm help:
NOTE Because svm_model contains pointers to svm_problem, you can
not free the memory used by svm_problem if you are still using the
svm_model produced by svm_train().
This causes LIBSVM package to randomly fail if julia garbage-collects the SVMProblem and nodes before calling svmpredict.
This patch solves the isue:
The text was updated successfully, but these errors were encountered: