{"action":"created","comment":{"url":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/comments/105565735","pull_request_review_id":26452242,"id":105565735,"diff_hunk":"@@ -1090,6 +1090,13 @@ def update_weights(self):\n         for i in xrange(len(self.wv.syn0), len(self.wv.vocab)):\n             # construct deterministic seed from word AND seed argument\n             newsyn0[i-len(self.wv.syn0)] = self.seeded_vector(self.wv.index2word[i] + str(self.seed))\n+\n+        # Raise an error if an online update is run before initial training on a corpus\n+        if not len(self.wv.syn0):\n+            raise RuntimeError(\"You can do an online update of vocabulary on a pre-trained model. \" \\","path":"gensim/models/word2vec.py","position":7,"original_position":7,"commit_id":"956dbbd1dc4ca0e9b798dafc48579f289f69808f","original_commit_id":"956dbbd1dc4ca0e9b798dafc48579f289f69808f","user":{"login":"gojomo","id":1641,"avatar_url":"https://avatars0.githubusercontent.com/u/1641?v=3","gravatar_id":"","url":"https://api.github.com/users/gojomo","html_url":"https://github.com/gojomo","followers_url":"https://api.github.com/users/gojomo/followers","following_url":"https://api.github.com/users/gojomo/following{/other_user}","gists_url":"https://api.github.com/users/gojomo/gists{/gist_id}","starred_url":"https://api.github.com/users/gojomo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gojomo/subscriptions","organizations_url":"https://api.github.com/users/gojomo/orgs","repos_url":"https://api.github.com/users/gojomo/repos","events_url":"https://api.github.com/users/gojomo/events{/privacy}","received_events_url":"https://api.github.com/users/gojomo/received_events","type":"User","site_admin":false},"body":"Note it isn't necessary any training has happened - just that no initial/prior vocabulary-discovery has happened (and the `update=True` case assumes that it has). So perhaps instead: \"Cannot update vocabulary of model which has no prior vocabulary.\"","created_at":"2017-03-12T19:02:31Z","updated_at":"2017-03-12T19:02:31Z","html_url":"https://github.com/RaRe-Technologies/gensim/pull/1205#discussion_r105565735","pull_request_url":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/1205","_links":{"self":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/comments/105565735"},"html":{"href":"https://github.com/RaRe-Technologies/gensim/pull/1205#discussion_r105565735"},"pull_request":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/1205"}}},"pull_request":{"url":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/1205","id":110244300,"html_url":"https://github.com/RaRe-Technologies/gensim/pull/1205","diff_url":"https://github.com/RaRe-Technologies/gensim/pull/1205.diff","patch_url":"https://github.com/RaRe-Technologies/gensim/pull/1205.patch","issue_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1205","number":1205,"state":"open","locked":false,"title":"Word2vec update before train error message. Fix #1162","user":{"login":"hemavakade","id":16784667,"avatar_url":"https://avatars3.githubusercontent.com/u/16784667?v=3","gravatar_id":"","url":"https://api.github.com/users/hemavakade","html_url":"https://github.com/hemavakade","followers_url":"https://api.github.com/users/hemavakade/followers","following_url":"https://api.github.com/users/hemavakade/following{/other_user}","gists_url":"https://api.github.com/users/hemavakade/gists{/gist_id}","starred_url":"https://api.github.com/users/hemavakade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hemavakade/subscriptions","organizations_url":"https://api.github.com/users/hemavakade/orgs","repos_url":"https://api.github.com/users/hemavakade/repos","events_url":"https://api.github.com/users/hemavakade/events{/privacy}","received_events_url":"https://api.github.com/users/hemavakade/received_events","type":"User","site_admin":false},"body":"Using Python 2.7.12 on MAC OSX VERSION 10.11.6 \r\nUsed Sublime Text Build 3126 to make changes\r\n\r\nReplicated the error by running the following \r\n\r\n```python\r\nimport gensim\r\nfrom nltk.corpus import brown, movie_reviews, treebank\r\nb = gensim.models.Word2Vec()\r\nb_sents = brown.sents()\r\nb.build_vocab(b_sents, keep_raw_vocab=False, trim_rule=None, progress_per=10000, update=True)\r\nb.train(b_sents)\r\n```\r\n\r\n**Error displayed:**\r\n```ValueError: all the input array dimensions except for the concatenation axis must match exactly```\r\n\r\nMade changes in file ```gensim\\models\\word2vec.py``` in the function ```update_weights```.\r\nAdded the following code which checks if the model weights have been initialized. \r\n(line 1072 - 1076)\r\n```python\r\n# Raise an error in an online update is run before initial training on a corpus\r\nif not len(self.wv.syn0):\r\n    raise RuntimeError(\"You can do an online update of vocabulary on a pre-trained model. \" \\\r\n       \"Or first build the vocabulary of your model with a corpus and train it \" \\\r\n       \"before doing an online update.\")\r\n```\r\n\r\n**Post-change testing:**\r\nI tested using the following  code:\r\n\r\n1) New Error message will be displayed instead of a `ValueError`\r\n\r\n```python\r\nimport gensim\r\nfrom nltk.corpus import brown, movie_reviews, treebank\r\nb = gensim.models.Word2Vec()\r\nb_sents = brown.sents()\r\nb.build_vocab(b_sents, keep_raw_vocab=False, trim_rule=None, progress_per=10000, update=True)\r\nb.train(b_sents)\r\n```\r\nand \r\n\r\n```python\r\nmodel = gensim.models.Word2Vec()\r\nsentences = gensim.models.word2vec.Text8Corpus('/path/to/text8')\r\nmodel.build_vocab(sentences, update=True)\r\nmodel.train(sentences)\r\n```\r\n\r\n2) No Error message will be displayed.\r\n\r\n```python\r\nimport gensim\r\nfrom nltk.corpus import brown, movie_reviews, treebank\r\nb = gensim.models.Word2Vec()\r\nb_sents = brown.sents()\r\nb.build_vocab(b_sents, keep_raw_vocab=False, trim_rule=None, progress_per=10000, update=False)\r\nb.train(b_sents)\r\nb.build_vocab(b_sents, keep_raw_vocab=False, trim_rule=None, progress_per=10000, update=True)\r\nb.train(b_sents)\r\n```\r\n\r\n```python\r\nmodel = gensim.models.Word2Vec()\r\nsentences = gensim.models.word2vec.Text8Corpus('/path/to/text8')\r\nmodel.build_vocab(sentences, update=False)\r\nmodel.train(sentences)\r\nmodel.build_vocab(sentences, update=True)\r\nmodel.train(sentences)\r\n```\r\n\r\n","created_at":"2017-03-11T03:15:49Z","updated_at":"2017-03-12T19:02:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bbf3ea2c342c4f75ee88d535e39e1797cca95678","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/1205/commits","review_comments_url":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/1205/comments","review_comment_url":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1205/comments","statuses_url":"https://api.github.com/repos/RaRe-Technologies/gensim/statuses/956dbbd1dc4ca0e9b798dafc48579f289f69808f","head":{"label":"hemavakade:bugfix-w2vupdon","ref":"bugfix-w2vupdon","sha":"956dbbd1dc4ca0e9b798dafc48579f289f69808f","user":{"login":"hemavakade","id":16784667,"avatar_url":"https://avatars3.githubusercontent.com/u/16784667?v=3","gravatar_id":"","url":"https://api.github.com/users/hemavakade","html_url":"https://github.com/hemavakade","followers_url":"https://api.github.com/users/hemavakade/followers","following_url":"https://api.github.com/users/hemavakade/following{/other_user}","gists_url":"https://api.github.com/users/hemavakade/gists{/gist_id}","starred_url":"https://api.github.com/users/hemavakade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hemavakade/subscriptions","organizations_url":"https://api.github.com/users/hemavakade/orgs","repos_url":"https://api.github.com/users/hemavakade/repos","events_url":"https://api.github.com/users/hemavakade/events{/privacy}","received_events_url":"https://api.github.com/users/hemavakade/received_events","type":"User","site_admin":false},"repo":{"id":84616588,"name":"gensim","full_name":"hemavakade/gensim","owner":{"login":"hemavakade","id":16784667,"avatar_url":"https://avatars3.githubusercontent.com/u/16784667?v=3","gravatar_id":"","url":"https://api.github.com/users/hemavakade","html_url":"https://github.com/hemavakade","followers_url":"https://api.github.com/users/hemavakade/followers","following_url":"https://api.github.com/users/hemavakade/following{/other_user}","gists_url":"https://api.github.com/users/hemavakade/gists{/gist_id}","starred_url":"https://api.github.com/users/hemavakade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hemavakade/subscriptions","organizations_url":"https://api.github.com/users/hemavakade/orgs","repos_url":"https://api.github.com/users/hemavakade/repos","events_url":"https://api.github.com/users/hemavakade/events{/privacy}","received_events_url":"https://api.github.com/users/hemavakade/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hemavakade/gensim","description":"Topic Modelling for Humans","fork":true,"url":"https://api.github.com/repos/hemavakade/gensim","forks_url":"https://api.github.com/repos/hemavakade/gensim/forks","keys_url":"https://api.github.com/repos/hemavakade/gensim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hemavakade/gensim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hemavakade/gensim/teams","hooks_url":"https://api.github.com/repos/hemavakade/gensim/hooks","issue_events_url":"https://api.github.com/repos/hemavakade/gensim/issues/events{/number}","events_url":"https://api.github.com/repos/hemavakade/gensim/events","assignees_url":"https://api.github.com/repos/hemavakade/gensim/assignees{/user}","branches_url":"https://api.github.com/repos/hemavakade/gensim/branches{/branch}","tags_url":"https://api.github.com/repos/hemavakade/gensim/tags","blobs_url":"https://api.github.com/repos/hemavakade/gensim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hemavakade/gensim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hemavakade/gensim/git/refs{/sha}","trees_url":"https://api.github.com/repos/hemavakade/gensim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hemavakade/gensim/statuses/{sha}","languages_url":"https://api.github.com/repos/hemavakade/gensim/languages","stargazers_url":"https://api.github.com/repos/hemavakade/gensim/stargazers","contributors_url":"https://api.github.com/repos/hemavakade/gensim/contributors","subscribers_url":"https://api.github.com/repos/hemavakade/gensim/subscribers","subscription_url":"https://api.github.com/repos/hemavakade/gensim/subscription","commits_url":"https://api.github.com/repos/hemavakade/gensim/commits{/sha}","git_commits_url":"https://api.github.com/repos/hemavakade/gensim/git/commits{/sha}","comments_url":"https://api.github.com/repos/hemavakade/gensim/comments{/number}","issue_comment_url":"https://api.github.com/repos/hemavakade/gensim/issues/comments{/number}","contents_url":"https://api.github.com/repos/hemavakade/gensim/contents/{+path}","compare_url":"https://api.github.com/repos/hemavakade/gensim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hemavakade/gensim/merges","archive_url":"https://api.github.com/repos/hemavakade/gensim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hemavakade/gensim/downloads","issues_url":"https://api.github.com/repos/hemavakade/gensim/issues{/number}","pulls_url":"https://api.github.com/repos/hemavakade/gensim/pulls{/number}","milestones_url":"https://api.github.com/repos/hemavakade/gensim/milestones{/number}","notifications_url":"https://api.github.com/repos/hemavakade/gensim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hemavakade/gensim/labels{/name}","releases_url":"https://api.github.com/repos/hemavakade/gensim/releases{/id}","deployments_url":"https://api.github.com/repos/hemavakade/gensim/deployments","created_at":"2017-03-11T02:06:16Z","updated_at":"2017-03-11T02:06:19Z","pushed_at":"2017-03-11T02:48:43Z","git_url":"git://github.com/hemavakade/gensim.git","ssh_url":"git@github.com:hemavakade/gensim.git","clone_url":"https://github.com/hemavakade/gensim.git","svn_url":"https://github.com/hemavakade/gensim","homepage":"http://radimrehurek.com/gensim/","size":31933,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"RaRe-Technologies:develop","ref":"develop","sha":"2f68ca959975f33212f5e2bb37bbb8def8b6742e","user":{"login":"RaRe-Technologies","id":12515886,"avatar_url":"https://avatars0.githubusercontent.com/u/12515886?v=3","gravatar_id":"","url":"https://api.github.com/users/RaRe-Technologies","html_url":"https://github.com/RaRe-Technologies","followers_url":"https://api.github.com/users/RaRe-Technologies/followers","following_url":"https://api.github.com/users/RaRe-Technologies/following{/other_user}","gists_url":"https://api.github.com/users/RaRe-Technologies/gists{/gist_id}","starred_url":"https://api.github.com/users/RaRe-Technologies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RaRe-Technologies/subscriptions","organizations_url":"https://api.github.com/users/RaRe-Technologies/orgs","repos_url":"https://api.github.com/users/RaRe-Technologies/repos","events_url":"https://api.github.com/users/RaRe-Technologies/events{/privacy}","received_events_url":"https://api.github.com/users/RaRe-Technologies/received_events","type":"Organization","site_admin":false},"repo":{"id":1349775,"name":"gensim","full_name":"RaRe-Technologies/gensim","owner":{"login":"RaRe-Technologies","id":12515886,"avatar_url":"https://avatars0.githubusercontent.com/u/12515886?v=3","gravatar_id":"","url":"https://api.github.com/users/RaRe-Technologies","html_url":"https://github.com/RaRe-Technologies","followers_url":"https://api.github.com/users/RaRe-Technologies/followers","following_url":"https://api.github.com/users/RaRe-Technologies/following{/other_user}","gists_url":"https://api.github.com/users/RaRe-Technologies/gists{/gist_id}","starred_url":"https://api.github.com/users/RaRe-Technologies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RaRe-Technologies/subscriptions","organizations_url":"https://api.github.com/users/RaRe-Technologies/orgs","repos_url":"https://api.github.com/users/RaRe-Technologies/repos","events_url":"https://api.github.com/users/RaRe-Technologies/events{/privacy}","received_events_url":"https://api.github.com/users/RaRe-Technologies/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RaRe-Technologies/gensim","description":"Topic Modelling for Humans","fork":false,"url":"https://api.github.com/repos/RaRe-Technologies/gensim","forks_url":"https://api.github.com/repos/RaRe-Technologies/gensim/forks","keys_url":"https://api.github.com/repos/RaRe-Technologies/gensim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RaRe-Technologies/gensim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RaRe-Technologies/gensim/teams","hooks_url":"https://api.github.com/repos/RaRe-Technologies/gensim/hooks","issue_events_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/events{/number}","events_url":"https://api.github.com/repos/RaRe-Technologies/gensim/events","assignees_url":"https://api.github.com/repos/RaRe-Technologies/gensim/assignees{/user}","branches_url":"https://api.github.com/repos/RaRe-Technologies/gensim/branches{/branch}","tags_url":"https://api.github.com/repos/RaRe-Technologies/gensim/tags","blobs_url":"https://api.github.com/repos/RaRe-Technologies/gensim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RaRe-Technologies/gensim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RaRe-Technologies/gensim/git/refs{/sha}","trees_url":"https://api.github.com/repos/RaRe-Technologies/gensim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RaRe-Technologies/gensim/statuses/{sha}","languages_url":"https://api.github.com/repos/RaRe-Technologies/gensim/languages","stargazers_url":"https://api.github.com/repos/RaRe-Technologies/gensim/stargazers","contributors_url":"https://api.github.com/repos/RaRe-Technologies/gensim/contributors","subscribers_url":"https://api.github.com/repos/RaRe-Technologies/gensim/subscribers","subscription_url":"https://api.github.com/repos/RaRe-Technologies/gensim/subscription","commits_url":"https://api.github.com/repos/RaRe-Technologies/gensim/commits{/sha}","git_commits_url":"https://api.github.com/repos/RaRe-Technologies/gensim/git/commits{/sha}","comments_url":"https://api.github.com/repos/RaRe-Technologies/gensim/comments{/number}","issue_comment_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/comments{/number}","contents_url":"https://api.github.com/repos/RaRe-Technologies/gensim/contents/{+path}","compare_url":"https://api.github.com/repos/RaRe-Technologies/gensim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RaRe-Technologies/gensim/merges","archive_url":"https://api.github.com/repos/RaRe-Technologies/gensim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RaRe-Technologies/gensim/downloads","issues_url":"https://api.github.com/repos/RaRe-Technologies/gensim/issues{/number}","pulls_url":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls{/number}","milestones_url":"https://api.github.com/repos/RaRe-Technologies/gensim/milestones{/number}","notifications_url":"https://api.github.com/repos/RaRe-Technologies/gensim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RaRe-Technologies/gensim/labels{/name}","releases_url":"https://api.github.com/repos/RaRe-Technologies/gensim/releases{/id}","deployments_url":"https://api.github.com/repos/RaRe-Technologies/gensim/deployments","created_at":"2011-02-10T07:43:04Z","updated_at":"2017-03-12T17:24:59Z","pushed_at":"2017-03-12T18:39:19Z","git_url":"git://github.com/RaRe-Technologies/gensim.git","ssh_url":"git@github.com:RaRe-Technologies/gensim.git","clone_url":"https://github.com/RaRe-Technologies/gensim.git","svn_url":"https://github.com/RaRe-Technologies/gensim","homepage":"http://radimrehurek.com/gensim/","size":31909,"stargazers_count":3885,"watchers_count":3885,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1457,"mirror_url":null,"open_issues_count":164,"forks":1457,"open_issues":164,"watchers":3885,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/1205"},"html":{"href":"https://github.com/RaRe-Technologies/gensim/pull/1205"},"issue":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1205"},"comments":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/issues/1205/comments"},"review_comments":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/1205/comments"},"review_comment":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/pulls/1205/commits"},"statuses":{"href":"https://api.github.com/repos/RaRe-Technologies/gensim/statuses/956dbbd1dc4ca0e9b798dafc48579f289f69808f"}}}}
{"actor":{"display_login":"gojomo"}}