Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void find_most_violated_constraint_marginrescaling(PATTERN x, LABEL y, LABEL *ybar, LATENT_VAR *hbar, STRUCTMODEL *sm, STRUCT_LEARN_PARM *sparm) {
- /*
- Finds the most violated constraint (loss-augmented inference), i.e.,
- computing argmax_{(ybar,hbar)} [<w,psi(x,ybar,hbar)> + loss(y,ybar,hbar)].
- The output (ybar,hbar) are stored at location pointed by
- pointers *ybar and *hbar.
- */
- int i;
- int width = x.width;
- int height = x.height;
- int cur_class, cur_position_x, cur_position_y;
- double max_score,score;
- double *hog;
- FILE *fp;
- max_score = -DBL_MAX;
- for(cur_position_x = 0; cur_position_x < width; cur_position_x++) {
- for(cur_position_y = 0; cur_position_y < height; cur_position_y++) {
- hog = x.hog[cur_position_x][cur_position_y];
- for(cur_class = 0; cur_class < sparm->n_classes; cur_class++) {
- score = 0;
- for(i = 0; i < sparm->size_hog; i++) {
- score += sm->w[cur_class*sparm->size_hog+i+1]*hog[i];
- }
- if(cur_class != y.label)
- score += 1;
- if(score > max_score) {
- max_score = score;
- ybar->label = cur_class;
- hbar->position_x = cur_position_x;
- hbar->position_y = cur_position_y;
- }
- }
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment