{"action":"created","comment":{"url":"https://api.github.com/repos/awslabs/sockeye/pulls/comments/134272992","pull_request_review_id":57545517,"id":134272992,"diff_hunk":"@@ -315,6 +315,39 @@ def sort_state(self, best_hyp_indices: mx.nd.NDArray, best_word_indices: mx.nd.N\n         self.decoder_states = [mx.nd.take(ds, best_hyp_indices) for ds in self.decoder_states]\n \n \n+class LengthPenalty:\n+    \"\"\"\n+    Calculates the length penalty as:\n+    (beta + len(Y))**alpha / (beta + 1)**alpha\n+\n+    See Wu et al. 2016.\n+\n+    :param alpha: The alpha factor for the length penalty (see above).\n+    :param beta: The beta factor for the length penalty (see above).\n+    \"\"\"\n+\n+    def __init__(self, alpha: float=1.0, beta: float=0.0):","path":"sockeye/inference.py","position":46,"original_position":46,"commit_id":"d69e40a9d03c3f80fcc3fba93fac6fdb428fdc16","original_commit_id":"d69e40a9d03c3f80fcc3fba93fac6fdb428fdc16","user":{"login":"fhieber","id":2027990,"avatar_url":"https://avatars2.githubusercontent.com/u/2027990?v=4","gravatar_id":"","url":"https://api.github.com/users/fhieber","html_url":"https://github.com/fhieber","followers_url":"https://api.github.com/users/fhieber/followers","following_url":"https://api.github.com/users/fhieber/following{/other_user}","gists_url":"https://api.github.com/users/fhieber/gists{/gist_id}","starred_url":"https://api.github.com/users/fhieber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhieber/subscriptions","organizations_url":"https://api.github.com/users/fhieber/orgs","repos_url":"https://api.github.com/users/fhieber/repos","events_url":"https://api.github.com/users/fhieber/events{/privacy}","received_events_url":"https://api.github.com/users/fhieber/received_events","type":"User","site_admin":false},"body":"could you add \"-> None\" to make code analyzers happy?","created_at":"2017-08-21T16:10:41Z","updated_at":"2017-08-21T16:12:25Z","html_url":"https://github.com/awslabs/sockeye/pull/115#discussion_r134272992","pull_request_url":"https://api.github.com/repos/awslabs/sockeye/pulls/115","_links":{"self":{"href":"https://api.github.com/repos/awslabs/sockeye/pulls/comments/134272992"},"html":{"href":"https://github.com/awslabs/sockeye/pull/115#discussion_r134272992"},"pull_request":{"href":"https://api.github.com/repos/awslabs/sockeye/pulls/115"}}},"pull_request":{"url":"https://api.github.com/repos/awslabs/sockeye/pulls/115","id":136793411,"html_url":"https://github.com/awslabs/sockeye/pull/115","diff_url":"https://github.com/awslabs/sockeye/pull/115.diff","patch_url":"https://github.com/awslabs/sockeye/pull/115.patch","issue_url":"https://api.github.com/repos/awslabs/sockeye/issues/115","number":115,"state":"open","locked":false,"title":"Parametrized length penalty for beam search.","user":{"login":"tdomhan","id":363737,"avatar_url":"https://avatars1.githubusercontent.com/u/363737?v=4","gravatar_id":"","url":"https://api.github.com/users/tdomhan","html_url":"https://github.com/tdomhan","followers_url":"https://api.github.com/users/tdomhan/followers","following_url":"https://api.github.com/users/tdomhan/following{/other_user}","gists_url":"https://api.github.com/users/tdomhan/gists{/gist_id}","starred_url":"https://api.github.com/users/tdomhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdomhan/subscriptions","organizations_url":"https://api.github.com/users/tdomhan/orgs","repos_url":"https://api.github.com/users/tdomhan/repos","events_url":"https://api.github.com/users/tdomhan/events{/privacy}","received_events_url":"https://api.github.com/users/tdomhan/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-21T16:02:30Z","updated_at":"2017-08-21T16:12:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6da3f044282896819f96a84b40c97c6734891484","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/awslabs/sockeye/pulls/115/commits","review_comments_url":"https://api.github.com/repos/awslabs/sockeye/pulls/115/comments","review_comment_url":"https://api.github.com/repos/awslabs/sockeye/pulls/comments{/number}","comments_url":"https://api.github.com/repos/awslabs/sockeye/issues/115/comments","statuses_url":"https://api.github.com/repos/awslabs/sockeye/statuses/d69e40a9d03c3f80fcc3fba93fac6fdb428fdc16","head":{"label":"tdomhan:length_penalty","ref":"length_penalty","sha":"d69e40a9d03c3f80fcc3fba93fac6fdb428fdc16","user":{"login":"tdomhan","id":363737,"avatar_url":"https://avatars1.githubusercontent.com/u/363737?v=4","gravatar_id":"","url":"https://api.github.com/users/tdomhan","html_url":"https://github.com/tdomhan","followers_url":"https://api.github.com/users/tdomhan/followers","following_url":"https://api.github.com/users/tdomhan/following{/other_user}","gists_url":"https://api.github.com/users/tdomhan/gists{/gist_id}","starred_url":"https://api.github.com/users/tdomhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdomhan/subscriptions","organizations_url":"https://api.github.com/users/tdomhan/orgs","repos_url":"https://api.github.com/users/tdomhan/repos","events_url":"https://api.github.com/users/tdomhan/events{/privacy}","received_events_url":"https://api.github.com/users/tdomhan/received_events","type":"User","site_admin":false},"repo":{"id":94216387,"name":"sockeye","full_name":"tdomhan/sockeye","owner":{"login":"tdomhan","id":363737,"avatar_url":"https://avatars1.githubusercontent.com/u/363737?v=4","gravatar_id":"","url":"https://api.github.com/users/tdomhan","html_url":"https://github.com/tdomhan","followers_url":"https://api.github.com/users/tdomhan/followers","following_url":"https://api.github.com/users/tdomhan/following{/other_user}","gists_url":"https://api.github.com/users/tdomhan/gists{/gist_id}","starred_url":"https://api.github.com/users/tdomhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdomhan/subscriptions","organizations_url":"https://api.github.com/users/tdomhan/orgs","repos_url":"https://api.github.com/users/tdomhan/repos","events_url":"https://api.github.com/users/tdomhan/events{/privacy}","received_events_url":"https://api.github.com/users/tdomhan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tdomhan/sockeye","description":"Sequence-to-sequence framework with a focus on Neural Machine Translation based on MXNet","fork":true,"url":"https://api.github.com/repos/tdomhan/sockeye","forks_url":"https://api.github.com/repos/tdomhan/sockeye/forks","keys_url":"https://api.github.com/repos/tdomhan/sockeye/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tdomhan/sockeye/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tdomhan/sockeye/teams","hooks_url":"https://api.github.com/repos/tdomhan/sockeye/hooks","issue_events_url":"https://api.github.com/repos/tdomhan/sockeye/issues/events{/number}","events_url":"https://api.github.com/repos/tdomhan/sockeye/events","assignees_url":"https://api.github.com/repos/tdomhan/sockeye/assignees{/user}","branches_url":"https://api.github.com/repos/tdomhan/sockeye/branches{/branch}","tags_url":"https://api.github.com/repos/tdomhan/sockeye/tags","blobs_url":"https://api.github.com/repos/tdomhan/sockeye/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tdomhan/sockeye/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tdomhan/sockeye/git/refs{/sha}","trees_url":"https://api.github.com/repos/tdomhan/sockeye/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tdomhan/sockeye/statuses/{sha}","languages_url":"https://api.github.com/repos/tdomhan/sockeye/languages","stargazers_url":"https://api.github.com/repos/tdomhan/sockeye/stargazers","contributors_url":"https://api.github.com/repos/tdomhan/sockeye/contributors","subscribers_url":"https://api.github.com/repos/tdomhan/sockeye/subscribers","subscription_url":"https://api.github.com/repos/tdomhan/sockeye/subscription","commits_url":"https://api.github.com/repos/tdomhan/sockeye/commits{/sha}","git_commits_url":"https://api.github.com/repos/tdomhan/sockeye/git/commits{/sha}","comments_url":"https://api.github.com/repos/tdomhan/sockeye/comments{/number}","issue_comment_url":"https://api.github.com/repos/tdomhan/sockeye/issues/comments{/number}","contents_url":"https://api.github.com/repos/tdomhan/sockeye/contents/{+path}","compare_url":"https://api.github.com/repos/tdomhan/sockeye/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tdomhan/sockeye/merges","archive_url":"https://api.github.com/repos/tdomhan/sockeye/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tdomhan/sockeye/downloads","issues_url":"https://api.github.com/repos/tdomhan/sockeye/issues{/number}","pulls_url":"https://api.github.com/repos/tdomhan/sockeye/pulls{/number}","milestones_url":"https://api.github.com/repos/tdomhan/sockeye/milestones{/number}","notifications_url":"https://api.github.com/repos/tdomhan/sockeye/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tdomhan/sockeye/labels{/name}","releases_url":"https://api.github.com/repos/tdomhan/sockeye/releases{/id}","deployments_url":"https://api.github.com/repos/tdomhan/sockeye/deployments","created_at":"2017-06-13T13:32:42Z","updated_at":"2017-06-21T09:41:40Z","pushed_at":"2017-08-21T16:01:48Z","git_url":"git://github.com/tdomhan/sockeye.git","ssh_url":"git@github.com:tdomhan/sockeye.git","clone_url":"https://github.com/tdomhan/sockeye.git","svn_url":"https://github.com/tdomhan/sockeye","homepage":"","size":477,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"awslabs:master","ref":"master","sha":"b005bb559c75f724ddec6e63bc822fa45d23b3b7","user":{"login":"awslabs","id":3299148,"avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":93721432,"name":"sockeye","full_name":"awslabs/sockeye","owner":{"login":"awslabs","id":3299148,"avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/awslabs/sockeye","description":"Sequence-to-sequence framework with a focus on Neural Machine Translation based on Apache MXNet","fork":false,"url":"https://api.github.com/repos/awslabs/sockeye","forks_url":"https://api.github.com/repos/awslabs/sockeye/forks","keys_url":"https://api.github.com/repos/awslabs/sockeye/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/sockeye/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/sockeye/teams","hooks_url":"https://api.github.com/repos/awslabs/sockeye/hooks","issue_events_url":"https://api.github.com/repos/awslabs/sockeye/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/sockeye/events","assignees_url":"https://api.github.com/repos/awslabs/sockeye/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/sockeye/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/sockeye/tags","blobs_url":"https://api.github.com/repos/awslabs/sockeye/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/sockeye/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/sockeye/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/sockeye/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/sockeye/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/sockeye/languages","stargazers_url":"https://api.github.com/repos/awslabs/sockeye/stargazers","contributors_url":"https://api.github.com/repos/awslabs/sockeye/contributors","subscribers_url":"https://api.github.com/repos/awslabs/sockeye/subscribers","subscription_url":"https://api.github.com/repos/awslabs/sockeye/subscription","commits_url":"https://api.github.com/repos/awslabs/sockeye/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/sockeye/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/sockeye/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/sockeye/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/sockeye/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/sockeye/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/sockeye/merges","archive_url":"https://api.github.com/repos/awslabs/sockeye/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/sockeye/downloads","issues_url":"https://api.github.com/repos/awslabs/sockeye/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/sockeye/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/sockeye/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/sockeye/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/sockeye/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/sockeye/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/sockeye/deployments","created_at":"2017-06-08T07:44:30Z","updated_at":"2017-08-13T22:44:19Z","pushed_at":"2017-08-21T16:02:31Z","git_url":"git://github.com/awslabs/sockeye.git","ssh_url":"git@github.com:awslabs/sockeye.git","clone_url":"https://github.com/awslabs/sockeye.git","svn_url":"https://github.com/awslabs/sockeye","homepage":"","size":631,"stargazers_count":185,"watchers_count":185,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":4,"forks":39,"open_issues":4,"watchers":185,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/awslabs/sockeye/pulls/115"},"html":{"href":"https://github.com/awslabs/sockeye/pull/115"},"issue":{"href":"https://api.github.com/repos/awslabs/sockeye/issues/115"},"comments":{"href":"https://api.github.com/repos/awslabs/sockeye/issues/115/comments"},"review_comments":{"href":"https://api.github.com/repos/awslabs/sockeye/pulls/115/comments"},"review_comment":{"href":"https://api.github.com/repos/awslabs/sockeye/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/awslabs/sockeye/pulls/115/commits"},"statuses":{"href":"https://api.github.com/repos/awslabs/sockeye/statuses/d69e40a9d03c3f80fcc3fba93fac6fdb428fdc16"}}}}
{"actor":{"display_login":"fhieber"}}