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

[WIP] Determinization #37

Closed
wants to merge 18 commits into from
Closed

[WIP] Determinization #37

wants to merge 18 commits into from

Conversation

danpovey
Copy link
Collaborator

This is still a work in progress, but closer to being finished.
Putting up a PR so you guys can see the code, it might give you some implementation ideas for things like epsilon removal.

@qindazhu
Copy link
Collaborator

OK, thanks. I'll implement RmEpsilons* as I have done with Wfsa.

@danpovey
Copy link
Collaborator Author

OK, this code is basically finished, but I haven't tried to compile it.
Does anyone (@qindazhu ?) want to try to compile it and debug it?
I don't want to be the only one who has some idea how it works; and
if there are aspects that are not well documened we can find them this way.

@qindazhu
Copy link
Collaborator

OK, will do

state_id(state_id),
arc_id(incoming_arc_index),
prev_state(src),
forward_prob(element->forward_prob + arc_weight) { }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src->forward_prob, right?

argue that this representation is unique. (If not, it won't matter actually;
it will just give us an output that's less minimal than it could be).
shared_ptr<LogSumTracebackState> prev_state;
// `prev_state` is the state that this points back to.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// pair<int32_t, float> for LogSumTracebackState.

// Constructor for the initial state of the determinized FSA
DetState(): seq_len(0), output_state(-1), normalized(true) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is output_state, it seems it's never used in DetState?

state->Normalize(wfsa_in, &arc_weight, &deriv_info);
int32_t next_state_id;
bool is_new_state = state_map->GetOutputState(state);
arcs_out->push_back({this->state_id, next_state_id, label});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this point to? what's next_state_id, seems we can remove this function as there is a function Normalize in DetState?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm.. maybe this function should not exist but should be inline code, if it's called only once now. this->state_id was the state id of the parent state, which is no longer in scope (was in ProcessArcs()). next_state_id should be state->state_id.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, possibly this function is never called and can be deleted.

det_state->Normalize(wfsa_in, &arc_weight, &deriv_info);
if (det_state->forward_backward_prob >= prune_cutoff) {
bool is_new_state = state_map->GetOutputState(state);
arcs_out->push_back({this->state_id, next_state_id, label});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetOutputState(det_state), right?
what's the new_state_id and label

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, GetOutputState(det_state). next_state_id == state->state_id. You can get label as iter->first.

arc_derivs_out->clear();

bool ans = map.GetOutputState(start_state.get());
CHECK(ans && ans->state_id == 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I remove ans->state_id?

@csukuangfj
Copy link
Collaborator

Can we close this one since it has already been merged in #41 ?

@danpovey danpovey closed this May 25, 2020
@qindazhu qindazhu deleted the determinization branch July 18, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants