Which model should I choose when I want to train two matrix?

1,702 views
Skip to first unread message

Kevin Lin

unread,
Apr 14, 2015, 2:30:52 AM4/14/15
to pyst...@googlegroups.com
I have two feature matrix.
One is video matrix which row is represent as the number of data, column is number of feature.(For an example: [ [0,0.5,1,0],[0,1,1,0.5] ] )
The other one is audio matrix.
The same, row is number of data and column is number of feature.( [ [1,0,0],[0.5,1,1] ]  )
Two matrix has different number of column.
Now, I want to let X as video matrix, Y as audio matrix to train the model.
That is, when I input a new x as video vector, I want to predict a y audio vector.
Is this available in structured learning?
If it's available, which model should I choose?

Thanks,
kevin

Andy

unread,
Apr 14, 2015, 1:34:36 PM4/14/15
to pyst...@googlegroups.com
Hi Kevin.
I'm not entirely sure what you are trying do to, but pystruct only deals with discrete outputs, so it can not predict a 0.5.

Best,
Andy
--
You received this message because you are subscribed to the Google Groups "pystruct" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystruct+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kevin Lin

unread,
Apr 14, 2015, 8:39:57 PM4/14/15
to pyst...@googlegroups.com

Thanks,Andy.
Another question is that when I use ssvm.fit(x,y).
I always got a "TypeError: No matching signature found".
How can I solve this error?

Andreas Mueller於 2015年4月15日星期三 UTC+8上午1時34分36秒寫道:

Andreas Mueller

unread,
Apr 15, 2015, 3:44:41 PM4/15/15
to pyst...@googlegroups.com
Can you give me the full traceback please?

Kevin Lin

unread,
Apr 27, 2015, 10:09:23 AM4/27/15
to pyst...@googlegroups.com
Here is the full traceback:

Traceback (most recent call last):
  File "test.py", line 277, in <module>
    ssvm.fit(video,audio)
  File "/usr/local/lib/python2.7/dist-packages/pystruct/learners/one_slack_ssvm.py", line 429, in fit
    joint_feature_gt = self.model.batch_joint_feature(X, Y)
  File "/usr/local/lib/python2.7/dist-packages/pystruct/models/unstructured_svm.py", line 247, in batch_joint_feature
    crammer_singer_joint_feature(X, Y, result)
  File "utils.pyx", line 14, in utils.__pyx_fused_cpdef (src/utils.c:2362)
TypeError: No matching signature found


My training data X has 379 data and each data has 376 feature ( X.shape = (379,376) )
My training label Y has 379 data and each data has 191 feature ( Y.shape = (379,191) )
I choose MultiLabelClF as model  to train

Andreas Mueller於 2015年4月16日星期四 UTC+8上午3時44分41秒寫道:

Andreas Mueller

unread,
Apr 28, 2015, 5:15:17 PM4/28/15
to pyst...@googlegroups.com
What is the dtype of Y and X?
Y should be integer.

Kevin Lin

unread,
May 11, 2015, 12:38:24 PM5/11/15
to pyst...@googlegroups.com
I tried to set the dtype of Y and X to "int".
But it still have the same TypeError: No matching signature found


Kevin Lin於 2015年4月14日星期二 UTC+8下午2時30分52秒寫道:

Andreas Mueller

unread,
May 11, 2015, 5:31:55 PM5/11/15
to pyst...@googlegroups.com
Can you please provide the full code and traceback?
--

Dong Wang

unread,
Jun 26, 2015, 5:16:44 AM6/26/15
to pyst...@googlegroups.com
Dear Kevin,

I have met a similar problem, that 
"  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)
TypeError: No matching signature found"

I wonder how you deal with it? Thank you so much.

Best,
Dong

Dong Wang

unread,
Jun 26, 2015, 5:23:44 AM6/26/15
to pyst...@googlegroups.com
Dear Andreas,

I have met a similar problem. Here are the simplified code and error information. Could you help me? Thank you so much!

code:
features_train = np.array([[[3,1,2,3],[3,1,2,3]],[[3,1,2,3],[3,1,2,3]]],'uint8')
features_test = np.array([[[3,1,2,3],[3,1,2,3]],[[3,1,2,3],[3,1,2,3]]],'uint8')
y_train = np.array([1,2])
y_test = np.array([1,2])
f_t = features_train
f_s = features_test
X_train =  [(features_i, np.vstack([np.arange(f_t.shape[0] - 1), np.arange(1, f_t.shape[0])]))  for features_i in f_t]
X_test = [(features_i, np.vstack([np.arange(f_t.shape[0] - 1), np.arange(1, f_t.shape[0])]))  for features_i in f_s]

model = GraphCRF(directed=True, inference_method="max-product")
ssvm =SubgradientSSVM(model=model, C=.1, max_iter=10)# FrankWolfeSSVM(
print ssvm.fit(X_train, y_train) 
print ssvm.score(X_test, y_test)

error information
Traceback (most recent call last):
  File "/home/jelly/workspace/testCRF/simTest.py", line 41, in <module>
    print ssvm.fit(X_train, y_train) 
  File "/home/jelly/.local/lib/python2.7/site-packages/pystruct/learners/subgradient_ssvm.py", line 199, in fit
    objective, positive_slacks, w = self._sequential_learning(X, Y, w)
  File "/home/jelly/.local/lib/python2.7/site-packages/pystruct/learners/subgradient_ssvm.py", line 287, in _sequential_learning
    find_constraint(self.model, x, y, w)
  File "/home/jelly/.local/lib/python2.7/site-packages/pystruct/utils/inference.py", line 65, in find_constraint
    y_hat = model.loss_augmented_inference(x, y, w, relaxed=relaxed)
  File "/home/jelly/.local/lib/python2.7/site-packages/pystruct/models/crf.py", line 106, in loss_augmented_inference
    loss_augment_unaries(unary_potentials, np.asarray(y), self.class_weight)
  File "utils.pyx", line 21, in utils.__pyx_fused_cpdef (src/utils.c:4341)
TypeError: No matching signature found

Dong Wang

unread,
Jun 26, 2015, 9:16:28 AM6/26/15
to pyst...@googlegroups.com
I have already known how to fix. It is the data format of my y_train......
Sorry for trouble. Thank you in the same way.


On Tuesday, May 12, 2015 at 5:31:55 AM UTC+8, Andreas Mueller wrote:

Kevin Lin

unread,
Jun 26, 2015, 11:30:20 PM6/26/15
to pyst...@googlegroups.com
Hi Dong,
Can I know how you modify your y_train?
Because I haven't solve my problem of my data.
Thanks!

Kevin

Dong Wang於 2015年6月26日星期五 UTC+8下午9時16分28秒寫道:

Andreas Mueller

unread,
Jun 30, 2015, 3:28:19 PM6/30/15
to pyst...@googlegroups.com
Sorry you couldn't figure out your problem.

Can you give a minimum example to reproduce?

Andy

Triet Chau

unread,
Nov 14, 2018, 11:19:49 AM11/14/18
to pystruct
This most probably mean the shape of your data does not meet that of PyStruct requirements.

The easiest way would be imitate one of their examples and make sure your data has same set as theirs

Best of luck 
Reply all
Reply to author
Forward
0 new messages