Fix crashes.

This commit is contained in:
Relintai 2023-12-29 19:35:55 +01:00
parent d4109a2d5b
commit c8b93a107b
3 changed files with 6 additions and 4 deletions

View File

@ -580,7 +580,7 @@ Ref<MLPPVector> MLPPCost::dual_form_svm_deriv(const Ref<MLPPVector> &alpha, cons
Ref<MLPPVector> alphaQDeriv = alg.mat_vec_multnv(Q, alpha);
Ref<MLPPVector> 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) {

View File

@ -166,7 +166,7 @@ void MLPPDualSVC::save(const String &file_name) {
//util.saveParameters(file_name, _alpha, _bias);
}
MLPPDualSVC::MLPPDualSVC(const Ref<MLPPMatrix> &p_input_set, const Ref<MLPPMatrix> &p_output_set, real_t p_C, KernelMethod p_kernel) {
MLPPDualSVC::MLPPDualSVC(const Ref<MLPPMatrix> &p_input_set, const Ref<MLPPVector> &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<MLPPMatrix> &p_input_set, const Ref<MLPPMatri
_C = p_C;
_kernel = p_kernel;
_z.instance();
_y_hat.instance();
_alpha.instance();
_y_hat->resize(_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.

View File

@ -37,7 +37,7 @@ public:
real_t score();
void save(const String &file_name);
MLPPDualSVC(const Ref<MLPPMatrix> &p_input_set, const Ref<MLPPMatrix> &p_output_set, real_t p_C, KernelMethod p_kernel = KERNEL_METHOD_LINEAR);
MLPPDualSVC(const Ref<MLPPMatrix> &p_input_set, const Ref<MLPPVector> &p_output_set, real_t p_C, KernelMethod p_kernel = KERNEL_METHOD_LINEAR);
MLPPDualSVC();
~MLPPDualSVC();