From c8b93a107b6bb46e32f9da313f06116e6b074917 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 29 Dec 2023 19:35:55 +0100 Subject: [PATCH] Fix crashes. --- mlpp/cost/cost.cpp | 2 +- mlpp/dual_svc/dual_svc.cpp | 6 ++++-- mlpp/dual_svc/dual_svc.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mlpp/cost/cost.cpp b/mlpp/cost/cost.cpp index ee145ab..97dbada 100644 --- a/mlpp/cost/cost.cpp +++ b/mlpp/cost/cost.cpp @@ -580,7 +580,7 @@ Ref MLPPCost::dual_form_svm_deriv(const Ref &alpha, cons Ref alphaQDeriv = alg.mat_vec_multnv(Q, alpha); Ref one = alg.onevecnv(alpha->size()); - return alg.subtractionnm(alphaQDeriv, one); + return alg.subtractionnv(alphaQDeriv, one); } MLPPCost::VectorCostFunctionPointer MLPPCost::get_cost_function_ptr_normal_vector(const MLPPCost::CostTypes cost) { diff --git a/mlpp/dual_svc/dual_svc.cpp b/mlpp/dual_svc/dual_svc.cpp index 039ec9c..edf58d0 100644 --- a/mlpp/dual_svc/dual_svc.cpp +++ b/mlpp/dual_svc/dual_svc.cpp @@ -166,7 +166,7 @@ void MLPPDualSVC::save(const String &file_name) { //util.saveParameters(file_name, _alpha, _bias); } -MLPPDualSVC::MLPPDualSVC(const Ref &p_input_set, const Ref &p_output_set, real_t p_C, KernelMethod p_kernel) { +MLPPDualSVC::MLPPDualSVC(const Ref &p_input_set, const Ref &p_output_set, real_t p_C, KernelMethod p_kernel) { _input_set = p_input_set; _output_set = p_output_set; _n = p_input_set->size().y; @@ -174,14 +174,16 @@ MLPPDualSVC::MLPPDualSVC(const Ref &p_input_set, const Refresize(_n); MLPPUtilities utils; _bias = utils.bias_initializationr(); - _alpha.instance(); _alpha->resize(_n); utils.weight_initializationv(_alpha); // One alpha for all training examples, as per the lagrangian multipliers. diff --git a/mlpp/dual_svc/dual_svc.h b/mlpp/dual_svc/dual_svc.h index 2ff6427..fc1a40b 100644 --- a/mlpp/dual_svc/dual_svc.h +++ b/mlpp/dual_svc/dual_svc.h @@ -37,7 +37,7 @@ public: real_t score(); void save(const String &file_name); - MLPPDualSVC(const Ref &p_input_set, const Ref &p_output_set, real_t p_C, KernelMethod p_kernel = KERNEL_METHOD_LINEAR); + MLPPDualSVC(const Ref &p_input_set, const Ref &p_output_set, real_t p_C, KernelMethod p_kernel = KERNEL_METHOD_LINEAR); MLPPDualSVC(); ~MLPPDualSVC();