Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using DirectorKernel with CrossValidation crashes in python #4120

Closed
dhelekal opened this issue Jan 25, 2018 · 3 comments
Closed

Using DirectorKernel with CrossValidation crashes in python #4120

dhelekal opened this issue Jan 25, 2018 · 3 comments
Labels

Comments

@dhelekal
Copy link
Contributor

OS family: Linux
Python 3.5 / Shogun 6.1.3 (Both conda)

Attempting to run CrossValidation on an mkl-svm containing a DirectorKernel throws:
RecursionError: maximum recursion depth exceeded while calling a Python object

Minimal working example:

from shogun import *
from numpy import *

class DirectorTestKernel(DirectorKernel):
    def __init__(self):
        DirectorKernel.__init__(self, True)
    def kernel_function(self, idx_a, idx_b):
        seq1 = self.get_lhs().get_feature_vector(idx_a)
        seq2 = self.get_rhs().get_feature_vector(idx_b)
        return dot(seq1, seq2)

feats_train=RealFeatures(identity(10))  
labels=BinaryLabels(array([1,1,1,1,1,-1,-1,-1,-1,-1]))   

ker1 = DirectorTestKernel()
ker2 = DirectorTestKernel()

#ker1 = GaussianKernel(1.0)  Test purposes, works with gaussiankernels
#ker2 = GaussianKernel(2.0) Test purposes, works with gaussiankernels

cker = CombinedKernel()

cker.append_kernel(ker1)
cker.append_kernel(ker2)

cft = CombinedFeatures()

cft.append_feature_obj(feats_train)
cft.append_feature_obj(feats_train)

cker.init(cft,cft)

libsvm = LibSVM()
svm = MKLClassification(libsvm)
svm.set_interleaved_optimization_enabled(False)
svm.set_kernel(cker)
svm.set_C_mkl(1000)
svm.set_mkl_norm(1)

Finally, running x-validation causes a crash:

splitting_strategy = StratifiedCrossValidationSplitting(labels, 2)
evaluation_criterium = AccuracyMeasure()
cross = CrossValidation(svm, cft, labels, splitting_strategy, evaluation_criterium)
cross.set_autolock(False)
cross.set_num_runs(2)

result = CrossValidationResult()
result = CrossValidationResult.obtain_from_generic(cross.evaluate())
@karlnapf
Copy link
Member

karlnapf commented Feb 2, 2018

Is this still a problem with your other fix in?

@stale
Copy link

stale bot commented Feb 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 26, 2020
@gf712
Copy link
Member

gf712 commented Feb 26, 2020

user hasn't replied in two years, closing for now

@gf712 gf712 closed this as completed Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants