{"action":"created","comment":{"url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments/59262196","id":59262196,"diff_hunk":"@@ -0,0 +1,210 @@\n+// nnet3/online-nnet3-decodable.cc\n+\n+// Copyright  2014  Johns Hopkins University (author: Daniel Povey)\n+//            2016  Api.ai (Author: Ilya Platonov)\n+\n+// See ../../COPYING for clarification regarding multiple authors\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//  http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\n+// WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\n+// MERCHANTABLITY OR NON-INFRINGEMENT.\n+// See the Apache 2 License for the specific language governing permissions and\n+// limitations under the License.\n+\n+#include \"nnet3/online-nnet3-decodable.h\"\n+#include \"nnet3/nnet-utils.h\"\n+\n+namespace kaldi {\n+namespace nnet3 {\n+\n+DecodableNnet3Online::DecodableNnet3Online(\n+    const AmNnetSimple &nnet,\n+    const TransitionModel &trans_model,\n+    const DecodableNnet3OnlineOptions &opts,\n+    OnlineFeatureInterface *input_feats):\n+    compiler_(nnet.GetNnet(), opts.optimize_config),\n+    features_(input_feats),\n+    nnet_(nnet),\n+    trans_model_(trans_model),\n+    opts_(opts),\n+    feat_dim_(input_feats->Dim()),\n+    num_pdfs_(nnet.GetNnet().OutputDim(\"output\")),\n+    begin_frame_(-1) {\n+  KALDI_ASSERT(opts_.max_nnet_batch_size > 0);\n+  log_priors_ = nnet_.Priors();\n+  KALDI_ASSERT((log_priors_.Dim() == 0 || log_priors_.Dim() == trans_model_.NumPdfs()) &&\n+               \"Priors in neural network must match with transition model (if exist).\");\n+\n+  ComputeSimpleNnetContext(nnet_.GetNnet(), &left_context_, &right_context_);\n+  log_priors_.ApplyLog();\n+}\n+\n+\n+\n+BaseFloat DecodableNnet3Online::LogLikelihood(int32 frame, int32 index) {\n+  ComputeForFrame(frame);\n+  int32 pdf_id = trans_model_.TransitionIdToPdf(index);\n+  KALDI_ASSERT(frame >= begin_frame_ &&\n+               frame < begin_frame_ + scaled_loglikes_.NumRows());\n+  return scaled_loglikes_(frame - begin_frame_, pdf_id);\n+}\n+\n+\n+bool DecodableNnet3Online::IsLastFrame(int32 frame) const {\n+  KALDI_ASSERT(false && \"Method is not imlemented\");\n+  return false;\n+}\n+\n+int32 DecodableNnet3Online::NumFramesReady() const {\n+  int32 features_ready = features_->NumFramesReady();\n+  if (features_ready == 0)\n+    return 0;\n+  bool input_finished = features_->IsLastFrame(features_ready - 1);\n+  if (opts_.pad_input) {\n+    // normal case... we'll pad with duplicates of first + last frame to get the\n+    // required left and right context.\n+    if (input_finished) return subsampling(features_ready);","path":"src/nnet3/online-nnet3-decodable.cc","position":73,"original_position":73,"commit_id":"75f8b027a2e6b6b679d26d0b4b667cea631ee6d1","original_commit_id":"75f8b027a2e6b6b679d26d0b4b667cea631ee6d1","user":{"login":"realill","id":8237297,"avatar_url":"https://avatars.githubusercontent.com/u/8237297?v=3","gravatar_id":"","url":"https://api.github.com/users/realill","html_url":"https://github.com/realill","followers_url":"https://api.github.com/users/realill/followers","following_url":"https://api.github.com/users/realill/following{/other_user}","gists_url":"https://api.github.com/users/realill/gists{/gist_id}","starred_url":"https://api.github.com/users/realill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realill/subscriptions","organizations_url":"https://api.github.com/users/realill/orgs","repos_url":"https://api.github.com/users/realill/repos","events_url":"https://api.github.com/users/realill/events{/privacy}","received_events_url":"https://api.github.com/users/realill/received_events","type":"User","site_admin":false},"body":"I created it because I was trying to use (num + frame_subsampling_factor  - 1)/(  frame_subsampling_factor) formula at first. It should stay, it makes code more readable. I will rename it.","created_at":"2016-04-11T19:05:32Z","updated_at":"2016-04-11T19:05:32Z","html_url":"https://github.com/kaldi-asr/kaldi/pull/666#discussion_r59262196","pull_request_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/666","_links":{"self":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments/59262196"},"html":{"href":"https://github.com/kaldi-asr/kaldi/pull/666#discussion_r59262196"},"pull_request":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/666"}}},"pull_request":{"url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/666","id":65547985,"html_url":"https://github.com/kaldi-asr/kaldi/pull/666","diff_url":"https://github.com/kaldi-asr/kaldi/pull/666.diff","patch_url":"https://github.com/kaldi-asr/kaldi/pull/666.patch","issue_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/666","number":666,"state":"open","locked":false,"title":"Online nnet3 code","user":{"login":"realill","id":8237297,"avatar_url":"https://avatars.githubusercontent.com/u/8237297?v=3","gravatar_id":"","url":"https://api.github.com/users/realill","html_url":"https://github.com/realill","followers_url":"https://api.github.com/users/realill/followers","following_url":"https://api.github.com/users/realill/following{/other_user}","gists_url":"https://api.github.com/users/realill/gists{/gist_id}","starred_url":"https://api.github.com/users/realill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realill/subscriptions","organizations_url":"https://api.github.com/users/realill/orgs","repos_url":"https://api.github.com/users/realill/repos","events_url":"https://api.github.com/users/realill/events{/privacy}","received_events_url":"https://api.github.com/users/realill/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-06T22:40:01Z","updated_at":"2016-04-11T19:05:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1bd74ca1a73fb7e3e73914fab050e2edf162ba23","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/666/commits","review_comments_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/666/comments","review_comment_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/666/comments","statuses_url":"https://api.github.com/repos/kaldi-asr/kaldi/statuses/75f8b027a2e6b6b679d26d0b4b667cea631ee6d1","head":{"label":"api-ai:chain","ref":"chain","sha":"75f8b027a2e6b6b679d26d0b4b667cea631ee6d1","user":{"login":"api-ai","id":8170782,"avatar_url":"https://avatars.githubusercontent.com/u/8170782?v=3","gravatar_id":"","url":"https://api.github.com/users/api-ai","html_url":"https://github.com/api-ai","followers_url":"https://api.github.com/users/api-ai/followers","following_url":"https://api.github.com/users/api-ai/following{/other_user}","gists_url":"https://api.github.com/users/api-ai/gists{/gist_id}","starred_url":"https://api.github.com/users/api-ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/api-ai/subscriptions","organizations_url":"https://api.github.com/users/api-ai/orgs","repos_url":"https://api.github.com/users/api-ai/repos","events_url":"https://api.github.com/users/api-ai/events{/privacy}","received_events_url":"https://api.github.com/users/api-ai/received_events","type":"Organization","site_admin":false},"repo":{"id":51176908,"name":"kaldi","full_name":"api-ai/kaldi","owner":{"login":"api-ai","id":8170782,"avatar_url":"https://avatars.githubusercontent.com/u/8170782?v=3","gravatar_id":"","url":"https://api.github.com/users/api-ai","html_url":"https://github.com/api-ai","followers_url":"https://api.github.com/users/api-ai/followers","following_url":"https://api.github.com/users/api-ai/following{/other_user}","gists_url":"https://api.github.com/users/api-ai/gists{/gist_id}","starred_url":"https://api.github.com/users/api-ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/api-ai/subscriptions","organizations_url":"https://api.github.com/users/api-ai/orgs","repos_url":"https://api.github.com/users/api-ai/repos","events_url":"https://api.github.com/users/api-ai/events{/privacy}","received_events_url":"https://api.github.com/users/api-ai/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/api-ai/kaldi","description":"This is now the official location of the Kaldi project.","fork":true,"url":"https://api.github.com/repos/api-ai/kaldi","forks_url":"https://api.github.com/repos/api-ai/kaldi/forks","keys_url":"https://api.github.com/repos/api-ai/kaldi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/api-ai/kaldi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/api-ai/kaldi/teams","hooks_url":"https://api.github.com/repos/api-ai/kaldi/hooks","issue_events_url":"https://api.github.com/repos/api-ai/kaldi/issues/events{/number}","events_url":"https://api.github.com/repos/api-ai/kaldi/events","assignees_url":"https://api.github.com/repos/api-ai/kaldi/assignees{/user}","branches_url":"https://api.github.com/repos/api-ai/kaldi/branches{/branch}","tags_url":"https://api.github.com/repos/api-ai/kaldi/tags","blobs_url":"https://api.github.com/repos/api-ai/kaldi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/api-ai/kaldi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/api-ai/kaldi/git/refs{/sha}","trees_url":"https://api.github.com/repos/api-ai/kaldi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/api-ai/kaldi/statuses/{sha}","languages_url":"https://api.github.com/repos/api-ai/kaldi/languages","stargazers_url":"https://api.github.com/repos/api-ai/kaldi/stargazers","contributors_url":"https://api.github.com/repos/api-ai/kaldi/contributors","subscribers_url":"https://api.github.com/repos/api-ai/kaldi/subscribers","subscription_url":"https://api.github.com/repos/api-ai/kaldi/subscription","commits_url":"https://api.github.com/repos/api-ai/kaldi/commits{/sha}","git_commits_url":"https://api.github.com/repos/api-ai/kaldi/git/commits{/sha}","comments_url":"https://api.github.com/repos/api-ai/kaldi/comments{/number}","issue_comment_url":"https://api.github.com/repos/api-ai/kaldi/issues/comments{/number}","contents_url":"https://api.github.com/repos/api-ai/kaldi/contents/{+path}","compare_url":"https://api.github.com/repos/api-ai/kaldi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/api-ai/kaldi/merges","archive_url":"https://api.github.com/repos/api-ai/kaldi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/api-ai/kaldi/downloads","issues_url":"https://api.github.com/repos/api-ai/kaldi/issues{/number}","pulls_url":"https://api.github.com/repos/api-ai/kaldi/pulls{/number}","milestones_url":"https://api.github.com/repos/api-ai/kaldi/milestones{/number}","notifications_url":"https://api.github.com/repos/api-ai/kaldi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/api-ai/kaldi/labels{/name}","releases_url":"https://api.github.com/repos/api-ai/kaldi/releases{/id}","deployments_url":"https://api.github.com/repos/api-ai/kaldi/deployments","created_at":"2016-02-05T22:02:52Z","updated_at":"2016-03-30T16:52:59Z","pushed_at":"2016-04-08T21:45:57Z","git_url":"git://github.com/api-ai/kaldi.git","ssh_url":"git@github.com:api-ai/kaldi.git","clone_url":"https://github.com/api-ai/kaldi.git","svn_url":"https://github.com/api-ai/kaldi","homepage":"http://kaldi-asr.org","size":101504,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"kaldi-asr:chain","ref":"chain","sha":"ce708ea1679467b915d50c5439eeb41a249e2d32","user":{"login":"kaldi-asr","id":11650082,"avatar_url":"https://avatars.githubusercontent.com/u/11650082?v=3","gravatar_id":"","url":"https://api.github.com/users/kaldi-asr","html_url":"https://github.com/kaldi-asr","followers_url":"https://api.github.com/users/kaldi-asr/followers","following_url":"https://api.github.com/users/kaldi-asr/following{/other_user}","gists_url":"https://api.github.com/users/kaldi-asr/gists{/gist_id}","starred_url":"https://api.github.com/users/kaldi-asr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaldi-asr/subscriptions","organizations_url":"https://api.github.com/users/kaldi-asr/orgs","repos_url":"https://api.github.com/users/kaldi-asr/repos","events_url":"https://api.github.com/users/kaldi-asr/events{/privacy}","received_events_url":"https://api.github.com/users/kaldi-asr/received_events","type":"Organization","site_admin":false},"repo":{"id":34275045,"name":"kaldi","full_name":"kaldi-asr/kaldi","owner":{"login":"kaldi-asr","id":11650082,"avatar_url":"https://avatars.githubusercontent.com/u/11650082?v=3","gravatar_id":"","url":"https://api.github.com/users/kaldi-asr","html_url":"https://github.com/kaldi-asr","followers_url":"https://api.github.com/users/kaldi-asr/followers","following_url":"https://api.github.com/users/kaldi-asr/following{/other_user}","gists_url":"https://api.github.com/users/kaldi-asr/gists{/gist_id}","starred_url":"https://api.github.com/users/kaldi-asr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaldi-asr/subscriptions","organizations_url":"https://api.github.com/users/kaldi-asr/orgs","repos_url":"https://api.github.com/users/kaldi-asr/repos","events_url":"https://api.github.com/users/kaldi-asr/events{/privacy}","received_events_url":"https://api.github.com/users/kaldi-asr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kaldi-asr/kaldi","description":"This is now the official location of the Kaldi project.","fork":false,"url":"https://api.github.com/repos/kaldi-asr/kaldi","forks_url":"https://api.github.com/repos/kaldi-asr/kaldi/forks","keys_url":"https://api.github.com/repos/kaldi-asr/kaldi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaldi-asr/kaldi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaldi-asr/kaldi/teams","hooks_url":"https://api.github.com/repos/kaldi-asr/kaldi/hooks","issue_events_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/events{/number}","events_url":"https://api.github.com/repos/kaldi-asr/kaldi/events","assignees_url":"https://api.github.com/repos/kaldi-asr/kaldi/assignees{/user}","branches_url":"https://api.github.com/repos/kaldi-asr/kaldi/branches{/branch}","tags_url":"https://api.github.com/repos/kaldi-asr/kaldi/tags","blobs_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaldi-asr/kaldi/statuses/{sha}","languages_url":"https://api.github.com/repos/kaldi-asr/kaldi/languages","stargazers_url":"https://api.github.com/repos/kaldi-asr/kaldi/stargazers","contributors_url":"https://api.github.com/repos/kaldi-asr/kaldi/contributors","subscribers_url":"https://api.github.com/repos/kaldi-asr/kaldi/subscribers","subscription_url":"https://api.github.com/repos/kaldi-asr/kaldi/subscription","commits_url":"https://api.github.com/repos/kaldi-asr/kaldi/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaldi-asr/kaldi/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaldi-asr/kaldi/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaldi-asr/kaldi/contents/{+path}","compare_url":"https://api.github.com/repos/kaldi-asr/kaldi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaldi-asr/kaldi/merges","archive_url":"https://api.github.com/repos/kaldi-asr/kaldi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaldi-asr/kaldi/downloads","issues_url":"https://api.github.com/repos/kaldi-asr/kaldi/issues{/number}","pulls_url":"https://api.github.com/repos/kaldi-asr/kaldi/pulls{/number}","milestones_url":"https://api.github.com/repos/kaldi-asr/kaldi/milestones{/number}","notifications_url":"https://api.github.com/repos/kaldi-asr/kaldi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaldi-asr/kaldi/labels{/name}","releases_url":"https://api.github.com/repos/kaldi-asr/kaldi/releases{/id}","deployments_url":"https://api.github.com/repos/kaldi-asr/kaldi/deployments","created_at":"2015-04-20T17:23:16Z","updated_at":"2016-04-11T13:52:55Z","pushed_at":"2016-04-11T18:13:26Z","git_url":"git://github.com/kaldi-asr/kaldi.git","ssh_url":"git@github.com:kaldi-asr/kaldi.git","clone_url":"https://github.com/kaldi-asr/kaldi.git","svn_url":"https://github.com/kaldi-asr/kaldi","homepage":"http://kaldi-asr.org","size":115620,"stargazers_count":547,"watchers_count":547,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":336,"mirror_url":null,"open_issues_count":60,"forks":336,"open_issues":60,"watchers":547,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/666"},"html":{"href":"https://github.com/kaldi-asr/kaldi/pull/666"},"issue":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/issues/666"},"comments":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/issues/666/comments"},"review_comments":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/666/comments"},"review_comment":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/pulls/666/commits"},"statuses":{"href":"https://api.github.com/repos/kaldi-asr/kaldi/statuses/75f8b027a2e6b6b679d26d0b4b667cea631ee6d1"}}}}