question about the edge features order

29 views
Skip to first unread message

杨少华

unread,
Dec 9, 2015, 4:06:22 PM12/9/15
to pystruct
Hi, I would like to use edge features, but I don't know how to arrange the edge features when they are related with the node labels.
For example, for a pairwise edge (y1,y2), both of y1 and y2 can take two values: 0 and 1. and when [y1,y2] = [0,0], the edge feature is [1,0,0];and when [y1,y2] = [0, 1], the edge feature is [0,1,0] etc. one way I thought is to cross product the feature with the values of y1 and y2. but how should I arrange them? Thanks.

Best Regards,
Shaohua Yang

Andreas Mueller

unread,
Dec 9, 2015, 4:46:48 PM12/9/15
to pyst...@googlegroups.com
Hi Shaohua.
The edge features are not conditional on the values of the nodes.
Each continuous edge-feature corresponds to one compatibility matrix that is weighted by this feature.
I think I need to draw a good image for that at some point.
If you use GraphCRF, there is a single 2x2 (for your binary nodes) matrix learned, encoding how good the values (y1=0,y2=0), (y1=1,y2=0), (0, 1) and (1, 1) are.
If you use EdgeFeatureGraphCRF, for each edge feature such a matrix will be learned, and they will all be summed up, weighted by the feature value.
If you have a single constant feature in EdgeFeatureGraphCRF, it is equivalent to GraphCRF, in learning a single 2x2 matrix.

Maybe the answer to your query is: there is an automatic cross product of the features with the values of y1 and y2.

Let me know if this clears things up.

Cheers,
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.

杨少华

unread,
Dec 9, 2015, 4:53:51 PM12/9/15
to pystruct
Thanks for your reply. so I understand every feature is share by all combinations of y1 and y2. even we only have 1 feature, we can learn 4 values(as we have 4 weights corresponding different combinations), is that correct? 

Best Regards,
Shaohua Yang

Andreas Mueller

unread,
Dec 9, 2015, 5:17:46 PM12/9/15
to pyst...@googlegroups.com

Indeed.

杨少华

unread,
Dec 9, 2015, 5:33:56 PM12/9/15
to pystruct
Is there any other option that I can adapt to the label depended feature? For my application, given different combinations, the features will be different. For example, if [y1,y2] = [0,0], the feature vector is f1, otherwise, the feature vector is f2. f1 and f2 are different kinds of features(even different dimensions). If we extend f1 to [f1,0] and f2 to [0,f2] to make them have same dimension. There are still some problems. That is to say, for each combination, we have different features, and we only hope to learn one weight vector for all these features such as [f1,0] and [0, f2].

Best Regards,
Shaohua Yang

Andreas Mueller

unread,
Dec 9, 2015, 6:17:51 PM12/9/15
to pyst...@googlegroups.com
I'm not sure I understand the model you want to learn.

In your model, the pairwise potential for (y1, y2) = (0, 0) is w1^T f1 (inner product?)
and for the other three combinations, you each have one feature vector? Or there are only two feature vectors, and for the other three combinations you
have different weight vectors, but the same feature vector?

Either way, this model is not implemented in pystruct, but would be not so hard to implement.
You simply have to overwrite the method in EdgeFeatureGraphCRF that computes the pairwise potentials, and make it compute them in the way you want.
As long as everything is linear in the parameters, that should be fine.

Andy
Reply all
Reply to author
Forward
0 new messages