{"action":"created","comment":{"url":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/comments/212703913","pull_request_review_id":149396188,"id":212703913,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjcwMzkxMw==","diff_hunk":"@@ -0,0 +1,60 @@\n+\"\"\"textCNN model.\"\"\"\n+\n+import gluonnlp as nlp\n+import mxnet as mx\n+from mxnet import gluon\n+from mxnet.gluon import HybridBlock\n+\n+class SentimentNet(HybridBlock):\n+    \"\"\"Network for sentiment analysis.\"\"\"\n+\n+    def __init__(self, dropout, embed_size=300, vocab_size=100, prefix=None,\n+                 params=None, model_mode='multichannel', output_size=2,\n+                 num_filters=(100, 100, 100), ngram_filter_sizes=(3, 4, 5)):\n+        super(SentimentNet, self).__init__(prefix=prefix, params=params)\n+        self.model_mode = model_mode\n+        with self.name_scope():\n+            self.embedding = gluon.nn.Embedding(vocab_size, embed_size)\n+            if self.model_mode == 'multichannel':\n+                self.embedding_extend = gluon.nn.Embedding(vocab_size, embed_size)\n+                embed_size *= 2\n+            self.encoder = nlp.model.ConvolutionalEncoder(embed_size=embed_size,\n+                                                          num_filters=num_filters,\n+                                                          ngram_filter_sizes=ngram_filter_sizes,\n+                                                          conv_layer_activation='relu',\n+                                                          num_highway=None)\n+            self.output = gluon.nn.HybridSequential()\n+            with self.output.name_scope():\n+                self.output.add(gluon.nn.Dropout(dropout))\n+                self.output.add(gluon.nn.Dense(output_size, flatten=False))\n+\n+    def hybrid_forward(self, F, data): # pylint: disable=arguments-differ\n+        if self.model_mode == 'multichannel':\n+            embedded = F.concat(self.embedding(data), self.embedding_extend(data), dim=2)\n+        else:\n+            embedded = self.embedding(data)\n+        encoded = self.encoder(embedded)  # Shape(T, N, C)\n+        out = self.output(encoded)\n+        return out\n+\n+def model(dropout, vocab, model_mode, output_size):\n+    \"\"\"Construct this model.\"\"\"\n+\n+    textCNN = SentimentNet(dropout=dropout, vocab_size=len(vocab), model_mode=model_mode,\\\n+                       output_size=output_size)\n+    textCNN.hybridize()\n+    return textCNN\n+\n+def init(textCNN, vocab, model_mode, context, lr):\n+    \"\"\"Initialization parameters.\"\"\"","path":"scripts/sentiment_analysis/text_cnn.py","position":49,"original_position":49,"commit_id":"80126f79c5fce9adaa8d9e3a313448ebe01e782f","original_commit_id":"80126f79c5fce9adaa8d9e3a313448ebe01e782f","user":{"login":"astonzhang","id":22279212,"node_id":"MDQ6VXNlcjIyMjc5MjEy","avatar_url":"https://avatars1.githubusercontent.com/u/22279212?v=4","gravatar_id":"","url":"https://api.github.com/users/astonzhang","html_url":"https://github.com/astonzhang","followers_url":"https://api.github.com/users/astonzhang/followers","following_url":"https://api.github.com/users/astonzhang/following{/other_user}","gists_url":"https://api.github.com/users/astonzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/astonzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astonzhang/subscriptions","organizations_url":"https://api.github.com/users/astonzhang/orgs","repos_url":"https://api.github.com/users/astonzhang/repos","events_url":"https://api.github.com/users/astonzhang/events{/privacy}","received_events_url":"https://api.github.com/users/astonzhang/received_events","type":"User","site_admin":false},"body":"Initialize","created_at":"2018-08-24T17:44:46Z","updated_at":"2018-08-24T17:45:41Z","html_url":"https://github.com/dmlc/gluon-nlp/pull/256#discussion_r212703913","pull_request_url":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/256","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/comments/212703913"},"html":{"href":"https://github.com/dmlc/gluon-nlp/pull/256#discussion_r212703913"},"pull_request":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/256"}}},"pull_request":{"url":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/256","id":206254114,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2MjU0MTE0","html_url":"https://github.com/dmlc/gluon-nlp/pull/256","diff_url":"https://github.com/dmlc/gluon-nlp/pull/256.diff","patch_url":"https://github.com/dmlc/gluon-nlp/pull/256.patch","issue_url":"https://api.github.com/repos/dmlc/gluon-nlp/issues/256","number":256,"state":"open","locked":false,"title":"add sentiment_analysis_cnn","user":{"login":"xiaotinghe","id":19492088,"node_id":"MDQ6VXNlcjE5NDkyMDg4","avatar_url":"https://avatars2.githubusercontent.com/u/19492088?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaotinghe","html_url":"https://github.com/xiaotinghe","followers_url":"https://api.github.com/users/xiaotinghe/followers","following_url":"https://api.github.com/users/xiaotinghe/following{/other_user}","gists_url":"https://api.github.com/users/xiaotinghe/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaotinghe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaotinghe/subscriptions","organizations_url":"https://api.github.com/users/xiaotinghe/orgs","repos_url":"https://api.github.com/users/xiaotinghe/repos","events_url":"https://api.github.com/users/xiaotinghe/events{/privacy}","received_events_url":"https://api.github.com/users/xiaotinghe/received_events","type":"User","site_admin":false},"body":"## Description ##\r\n(Brief description on what this PR is about)\r\n\r\n## Checklist ##\r\n### Essentials ###\r\n- [ ] Changes are complete (i.e. I finished coding on this PR)\r\n- [ ] All changes have test coverage\r\n- [ ] Code is well-documented\r\n\r\n### Changes ###\r\n- [ ] Feature1, tests, (and when applicable, API doc)\r\n- [ ] Feature2, tests, (and when applicable, API doc)\r\n\r\n## Comments ##\r\n- If this change is a backward incompatible change, why must this change be made.\r\n- Interesting edge cases to note here\r\n","created_at":"2018-08-05T19:35:51Z","updated_at":"2018-08-24T17:45:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"091a105e18ece8223e2326a155f687458b080bd5","assignee":null,"assignees":[],"requested_reviewers":[{"login":"szha","id":2626883,"node_id":"MDQ6VXNlcjI2MjY4ODM=","avatar_url":"https://avatars2.githubusercontent.com/u/2626883?v=4","gravatar_id":"","url":"https://api.github.com/users/szha","html_url":"https://github.com/szha","followers_url":"https://api.github.com/users/szha/followers","following_url":"https://api.github.com/users/szha/following{/other_user}","gists_url":"https://api.github.com/users/szha/gists{/gist_id}","starred_url":"https://api.github.com/users/szha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szha/subscriptions","organizations_url":"https://api.github.com/users/szha/orgs","repos_url":"https://api.github.com/users/szha/repos","events_url":"https://api.github.com/users/szha/events{/privacy}","received_events_url":"https://api.github.com/users/szha/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/256/commits","review_comments_url":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/256/comments","review_comment_url":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dmlc/gluon-nlp/issues/256/comments","statuses_url":"https://api.github.com/repos/dmlc/gluon-nlp/statuses/80126f79c5fce9adaa8d9e3a313448ebe01e782f","head":{"label":"xiaotinghe:master","ref":"master","sha":"80126f79c5fce9adaa8d9e3a313448ebe01e782f","user":{"login":"xiaotinghe","id":19492088,"node_id":"MDQ6VXNlcjE5NDkyMDg4","avatar_url":"https://avatars2.githubusercontent.com/u/19492088?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaotinghe","html_url":"https://github.com/xiaotinghe","followers_url":"https://api.github.com/users/xiaotinghe/followers","following_url":"https://api.github.com/users/xiaotinghe/following{/other_user}","gists_url":"https://api.github.com/users/xiaotinghe/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaotinghe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaotinghe/subscriptions","organizations_url":"https://api.github.com/users/xiaotinghe/orgs","repos_url":"https://api.github.com/users/xiaotinghe/repos","events_url":"https://api.github.com/users/xiaotinghe/events{/privacy}","received_events_url":"https://api.github.com/users/xiaotinghe/received_events","type":"User","site_admin":false},"repo":{"id":143246415,"node_id":"MDEwOlJlcG9zaXRvcnkxNDMyNDY0MTU=","name":"gluon-nlp","full_name":"xiaotinghe/gluon-nlp","owner":{"login":"xiaotinghe","id":19492088,"node_id":"MDQ6VXNlcjE5NDkyMDg4","avatar_url":"https://avatars2.githubusercontent.com/u/19492088?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaotinghe","html_url":"https://github.com/xiaotinghe","followers_url":"https://api.github.com/users/xiaotinghe/followers","following_url":"https://api.github.com/users/xiaotinghe/following{/other_user}","gists_url":"https://api.github.com/users/xiaotinghe/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaotinghe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaotinghe/subscriptions","organizations_url":"https://api.github.com/users/xiaotinghe/orgs","repos_url":"https://api.github.com/users/xiaotinghe/repos","events_url":"https://api.github.com/users/xiaotinghe/events{/privacy}","received_events_url":"https://api.github.com/users/xiaotinghe/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xiaotinghe/gluon-nlp","description":"NLP made easy","fork":true,"url":"https://api.github.com/repos/xiaotinghe/gluon-nlp","forks_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/forks","keys_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/teams","hooks_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/hooks","issue_events_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/issues/events{/number}","events_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/events","assignees_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/assignees{/user}","branches_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/branches{/branch}","tags_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/tags","blobs_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/git/refs{/sha}","trees_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/statuses/{sha}","languages_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/languages","stargazers_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/stargazers","contributors_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/contributors","subscribers_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/subscribers","subscription_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/subscription","commits_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/commits{/sha}","git_commits_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/git/commits{/sha}","comments_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/comments{/number}","issue_comment_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/issues/comments{/number}","contents_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/contents/{+path}","compare_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/merges","archive_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/downloads","issues_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/issues{/number}","pulls_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/pulls{/number}","milestones_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/milestones{/number}","notifications_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/labels{/name}","releases_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/releases{/id}","deployments_url":"https://api.github.com/repos/xiaotinghe/gluon-nlp/deployments","created_at":"2018-08-02T05:26:02Z","updated_at":"2018-08-24T17:39:23Z","pushed_at":"2018-08-24T17:39:21Z","git_url":"git://github.com/xiaotinghe/gluon-nlp.git","ssh_url":"git@github.com:xiaotinghe/gluon-nlp.git","clone_url":"https://github.com/xiaotinghe/gluon-nlp.git","svn_url":"https://github.com/xiaotinghe/gluon-nlp","homepage":"http://gluon-nlp.mxnet.io","size":1797,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dmlc:sentiment","ref":"sentiment","sha":"d3634fc118a8779bbff1bb94d481a5b0063d1374","user":{"login":"dmlc","id":11508361,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNTA4MzYx","avatar_url":"https://avatars2.githubusercontent.com/u/11508361?v=4","gravatar_id":"","url":"https://api.github.com/users/dmlc","html_url":"https://github.com/dmlc","followers_url":"https://api.github.com/users/dmlc/followers","following_url":"https://api.github.com/users/dmlc/following{/other_user}","gists_url":"https://api.github.com/users/dmlc/gists{/gist_id}","starred_url":"https://api.github.com/users/dmlc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmlc/subscriptions","organizations_url":"https://api.github.com/users/dmlc/orgs","repos_url":"https://api.github.com/users/dmlc/repos","events_url":"https://api.github.com/users/dmlc/events{/privacy}","received_events_url":"https://api.github.com/users/dmlc/received_events","type":"Organization","site_admin":false},"repo":{"id":128121076,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgxMjEwNzY=","name":"gluon-nlp","full_name":"dmlc/gluon-nlp","owner":{"login":"dmlc","id":11508361,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNTA4MzYx","avatar_url":"https://avatars2.githubusercontent.com/u/11508361?v=4","gravatar_id":"","url":"https://api.github.com/users/dmlc","html_url":"https://github.com/dmlc","followers_url":"https://api.github.com/users/dmlc/followers","following_url":"https://api.github.com/users/dmlc/following{/other_user}","gists_url":"https://api.github.com/users/dmlc/gists{/gist_id}","starred_url":"https://api.github.com/users/dmlc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmlc/subscriptions","organizations_url":"https://api.github.com/users/dmlc/orgs","repos_url":"https://api.github.com/users/dmlc/repos","events_url":"https://api.github.com/users/dmlc/events{/privacy}","received_events_url":"https://api.github.com/users/dmlc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dmlc/gluon-nlp","description":"NLP made easy","fork":false,"url":"https://api.github.com/repos/dmlc/gluon-nlp","forks_url":"https://api.github.com/repos/dmlc/gluon-nlp/forks","keys_url":"https://api.github.com/repos/dmlc/gluon-nlp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmlc/gluon-nlp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmlc/gluon-nlp/teams","hooks_url":"https://api.github.com/repos/dmlc/gluon-nlp/hooks","issue_events_url":"https://api.github.com/repos/dmlc/gluon-nlp/issues/events{/number}","events_url":"https://api.github.com/repos/dmlc/gluon-nlp/events","assignees_url":"https://api.github.com/repos/dmlc/gluon-nlp/assignees{/user}","branches_url":"https://api.github.com/repos/dmlc/gluon-nlp/branches{/branch}","tags_url":"https://api.github.com/repos/dmlc/gluon-nlp/tags","blobs_url":"https://api.github.com/repos/dmlc/gluon-nlp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmlc/gluon-nlp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmlc/gluon-nlp/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmlc/gluon-nlp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmlc/gluon-nlp/statuses/{sha}","languages_url":"https://api.github.com/repos/dmlc/gluon-nlp/languages","stargazers_url":"https://api.github.com/repos/dmlc/gluon-nlp/stargazers","contributors_url":"https://api.github.com/repos/dmlc/gluon-nlp/contributors","subscribers_url":"https://api.github.com/repos/dmlc/gluon-nlp/subscribers","subscription_url":"https://api.github.com/repos/dmlc/gluon-nlp/subscription","commits_url":"https://api.github.com/repos/dmlc/gluon-nlp/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmlc/gluon-nlp/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmlc/gluon-nlp/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmlc/gluon-nlp/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmlc/gluon-nlp/contents/{+path}","compare_url":"https://api.github.com/repos/dmlc/gluon-nlp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmlc/gluon-nlp/merges","archive_url":"https://api.github.com/repos/dmlc/gluon-nlp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmlc/gluon-nlp/downloads","issues_url":"https://api.github.com/repos/dmlc/gluon-nlp/issues{/number}","pulls_url":"https://api.github.com/repos/dmlc/gluon-nlp/pulls{/number}","milestones_url":"https://api.github.com/repos/dmlc/gluon-nlp/milestones{/number}","notifications_url":"https://api.github.com/repos/dmlc/gluon-nlp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmlc/gluon-nlp/labels{/name}","releases_url":"https://api.github.com/repos/dmlc/gluon-nlp/releases{/id}","deployments_url":"https://api.github.com/repos/dmlc/gluon-nlp/deployments","created_at":"2018-04-04T20:57:13Z","updated_at":"2018-08-23T22:24:46Z","pushed_at":"2018-08-24T17:39:22Z","git_url":"git://github.com/dmlc/gluon-nlp.git","ssh_url":"git@github.com:dmlc/gluon-nlp.git","clone_url":"https://github.com/dmlc/gluon-nlp.git","svn_url":"https://github.com/dmlc/gluon-nlp","homepage":"http://gluon-nlp.mxnet.io","size":1959,"stargazers_count":898,"watchers_count":898,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":166,"mirror_url":null,"archived":false,"open_issues_count":36,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":166,"open_issues":36,"watchers":898,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/256"},"html":{"href":"https://github.com/dmlc/gluon-nlp/pull/256"},"issue":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/issues/256"},"comments":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/issues/256/comments"},"review_comments":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/256/comments"},"review_comment":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/pulls/256/commits"},"statuses":{"href":"https://api.github.com/repos/dmlc/gluon-nlp/statuses/80126f79c5fce9adaa8d9e3a313448ebe01e782f"}},"author_association":"NONE"}}
{"actor":{"display_login":"astonzhang"}}