Hi Heiko, thanks for reply.

The mentioned warning disappeared. I had time for analyzing a bit more the
issue, which persists. The problem takes place when I try to use any kernel
which uses a precomputed distance object ('dst' in the attached code
snippet). I tested the both, the sparse and dense versions of the
'EulideanDistance' object. For the Gaussian, Linear and Polynomial kernels
(uniquely for these kernels) it is not needed a precomputed distance
matrix, so all works fine with them.

I attached my Python code in the mail before. Do you have it?
El 13/12/2015 16:23, "Heiko Strathmann" <[email protected]>
escribió:

> Hi Nacho,
>
> this seems like a bug. Could you put the snippet on github issues? I will
> try to look at it there.
>
> H
>
>
>
> 2015-12-01 19:51 GMT+00:00 nacho arroyo <[email protected]>:
>
>> Hi all,
>>
>> Some days ago I was trying to train a MKL object by using sparse
>> features. Different issues have occurred. This time, I saved and loaded a
>> sparse matrix containing dummy data for training a MKLRegression object.
>>
>> I could create Sparse feature objects successfully. However, when I call
>> train() method of the MKLRegression object an error is given. See the
>> code snippet below for the CauchyKernel():
>>
>> In [2]: from modshogun import *
>> In [3]: from scipy.io import mmread
>> In [4]: from tools.load import LoadMatrix
>> In [5]: sci_train_data_x =
>> mmread('sparse_train.mtx').asformat('csr').astype('float64')
>> In [6]: feats_train = SparseRealFeatures(sci_train_data_x)
>> In [8]: lm = LoadMatrix()
>> In [9]: labels_tr =
>> RegressionLabels(lm.load_labels('labelSparse_train.mtx'))
>> In [10]: k0 = PolyKernel(10,3)
>> In [11]: dist = SparseEuclideanDistance(feats_train,feats_train)
>> In [12]: k1 = CauchyKernel(0, 10, dist)
>> In [13]: k0.init(feats_train,feats_train)
>> Out[13]: True
>> In [14]: k1.init(feats_train,feats_train)
>> Out[14]: True
>> In [15]: k = CombinedKernel()
>> In [16]: k.append_kernel(k0)
>> Out[16]: True
>> In [17]: k.append_kernel(k1)
>> Out[17]: True
>> In [18]: k.init(feats_train,feats_train)
>> Out[18]: True
>> In [19]: mkl = MKLRegression()
>> In [20]: mkl.set_C(1,1)
>> In [21]: mkl.set_mkl_norm(2)
>> In [22]: mkl.set_kernel(k)
>> In [23]: mkl.set_labels(labels_tr)
>> In [24]: mkl.train()
>>
>> ---------------------------------------------------------------------------
>> SystemError                               Traceback (most recent call
>> last)
>> <ipython-input-24-ba4aba7733e3> in <module>()
>> ----> 1 mkl.train()
>>
>> SystemError: [ERROR] In file
>> /home/iarroyof/shogun/src/shogun/features/SparseFeatures.cpp line 408:
>> assertion bvec.features failed in float64_t
>> shogun::CSparseFeatures<ST>::compute_squared_norm(shogun::CSparseFeatures<double>*,
>> float64_t*, int32_t, shogun::CSparseFeatures<double>*, float64_t*, int32_t)
>> [with ST = double; float64_t = double; int32_t = int] file
>> /home/iarroyof/shogun/src/shogun/features/SparseFeatures.cpp line 408
>>
>> Up to I can observe by going in the code where ASSERTion is placed, it
>> seems to be there is a type disagreement or probably the ASSERT method does
>> not find data for computing distance. Any way, I don't know how to fix this
>> error. Furthermore, a warning is given for other kernels like Gaussian or
>> Wave. In these cases, no any distance is explicitly computed:
>>
>> /usr/lib/python2.7/dist-packages/numpy/core/_methods.py:55:
>> RuntimeWarning: Mean of empty slice.
>>   warnings.warn("Mean of empty slice.", RuntimeWarning)
>> /usr/lib/python2.7/dist-packages/numpy/core/_methods.py:67:
>> RuntimeWarning: invalid value encountered in double_scalars
>>   ret = ret.dtype.type(ret / rcount)
>>
>> In some part of the Shogun class reference I saw SparseRealKernel and
>> I'm wondering if using common kernels (maybe exclusively dense kernels) is
>> not compatible with sparse features.
>>
>> Thank you very much in advance for your help.
>>
>> --
>> *Ignacio Arroyo-Fernández*
>>
>
>

Reply via email to