{"action":"created","comment":{"url":"https://api.github.com/repos/keras-team/keras/pulls/comments/214421352","pull_request_review_id":151482453,"id":214421352,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNDQyMTM1Mg==","diff_hunk":"@@ -0,0 +1,197 @@\n+\"\"\"HDF5 related utilities.\"\"\"\n+import numpy as np\n+import sys\n+\n+\n+try:\n+    import h5py\n+    HDF5_OBJECT_HEADER_LIMIT = 64512\n+except ImportError:\n+    h5py = None\n+\n+\n+if sys.version_info[0] == 3:\n+    import pickle\n+else:\n+    import cPickle as pickle\n+\n+\n+# FLAGS\n+_is_boxed = '_is_dict_boxed'\n+\n+\n+class H5Dict(object):\n+    \"\"\" A dict-like wrapper around h5py groups (or dicts).\n+\n+    This allows us to have a single serialization logic\n+    for both pickling and saving to disk.\n+\n+    Note: This is not intended to be a generic wrapper.\n+    There are lot of edge cases which have been hardcoded,\n+    and makes sense only in the context of model serialization/\n+    deserialization.\n+    \"\"\"\n+\n+    def __init__(self, path, mode='a'):\n+        if isinstance(path, h5py.Group):\n+            self.data = path\n+            self._is_file = False\n+        elif type(path) is str:\n+            self.data = h5py.File(path,)\n+            self._is_file = True\n+        elif type(path) is dict:\n+            self.data = path\n+            self._is_file = False\n+            self.data[_is_boxed] = True\n+        else:\n+            raise Exception('Required Group, str or dict.'\n+                            ' Received {}.'.format(type(path)))\n+        self.read_only = mode == 'r'\n+\n+    def __setitem__(self, attr, val):\n+        if self.read_only:\n+            raise Exception('Can not set item in read only mode.')\n+        is_np = type(val).__module__ == np.__name__\n+        if type(self.data) is dict:\n+            if type(attr) is bytes:\n+                attr = attr.decode('utf-8')\n+            if is_np:\n+                self.data[attr] = pickle.dumps(val)\n+                # We have to remeber to unpickle in __getitem__\n+                self.data['_{}_pickled'.format(attr)] = True\n+            else:\n+                self.data[attr] = val\n+            return\n+        if attr in self:\n+            raise Exception('Can not set attribute.'\n+                            ' Group with name {} exists.'.format(attr))\n+        if is_np:\n+            dataset = self.data.create_dataset(attr, val.shape, dtype=val.dtype)\n+            if not val.shape:\n+                # scalar\n+                dataset[()] = val\n+            else:\n+                dataset[:] = val\n+        if isinstance(val, list):\n+            # Check that no item in `data` is larger than `HDF5_OBJECT_HEADER_LIMIT`\n+            # because in that case even chunking the array would not make the saving\n+            # possible.\n+            bad_attributes = [x for x in val if len(x) > HDF5_OBJECT_HEADER_LIMIT]\n+\n+            # Expecting this to never be true.\n+            if len(bad_attributes) > 0:\n+                raise RuntimeError('The following attributes cannot be saved to HDF5 '\n+                                   'file because they are larger than %d bytes: %s'\n+                                   % (HDF5_OBJECT_HEADER_LIMIT,\n+                                      ', '.join([x for x in bad_attributes])))","path":"keras/utils/hdf5_utils.py","position":86,"original_position":86,"commit_id":"0a8430c03b3b7db09ce87a965b1ca49652666fb0","original_commit_id":"0a8430c03b3b7db09ce87a965b1ca49652666fb0","user":{"login":"joelthchao","id":10974532,"node_id":"MDQ6VXNlcjEwOTc0NTMy","avatar_url":"https://avatars3.githubusercontent.com/u/10974532?v=4","gravatar_id":"","url":"https://api.github.com/users/joelthchao","html_url":"https://github.com/joelthchao","followers_url":"https://api.github.com/users/joelthchao/followers","following_url":"https://api.github.com/users/joelthchao/following{/other_user}","gists_url":"https://api.github.com/users/joelthchao/gists{/gist_id}","starred_url":"https://api.github.com/users/joelthchao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelthchao/subscriptions","organizations_url":"https://api.github.com/users/joelthchao/orgs","repos_url":"https://api.github.com/users/joelthchao/repos","events_url":"https://api.github.com/users/joelthchao/events{/privacy}","received_events_url":"https://api.github.com/users/joelthchao/received_events","type":"User","site_admin":false},"body":"Redundant list comprehension","created_at":"2018-08-31T17:20:02Z","updated_at":"2018-08-31T17:20:02Z","html_url":"https://github.com/keras-team/keras/pull/11030#discussion_r214421352","pull_request_url":"https://api.github.com/repos/keras-team/keras/pulls/11030","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/keras-team/keras/pulls/comments/214421352"},"html":{"href":"https://github.com/keras-team/keras/pull/11030#discussion_r214421352"},"pull_request":{"href":"https://api.github.com/repos/keras-team/keras/pulls/11030"}}},"pull_request":{"url":"https://api.github.com/repos/keras-team/keras/pulls/11030","id":211983362,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExOTgzMzYy","html_url":"https://github.com/keras-team/keras/pull/11030","diff_url":"https://github.com/keras-team/keras/pull/11030.diff","patch_url":"https://github.com/keras-team/keras/pull/11030.patch","issue_url":"https://api.github.com/repos/keras-team/keras/issues/11030","number":11030,"state":"open","locked":false,"title":"Make Keras models pickle-able (refactored)","user":{"login":"farizrahman4u","id":11006006,"node_id":"MDQ6VXNlcjExMDA2MDA2","avatar_url":"https://avatars0.githubusercontent.com/u/11006006?v=4","gravatar_id":"","url":"https://api.github.com/users/farizrahman4u","html_url":"https://github.com/farizrahman4u","followers_url":"https://api.github.com/users/farizrahman4u/followers","following_url":"https://api.github.com/users/farizrahman4u/following{/other_user}","gists_url":"https://api.github.com/users/farizrahman4u/gists{/gist_id}","starred_url":"https://api.github.com/users/farizrahman4u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/farizrahman4u/subscriptions","organizations_url":"https://api.github.com/users/farizrahman4u/orgs","repos_url":"https://api.github.com/users/farizrahman4u/repos","events_url":"https://api.github.com/users/farizrahman4u/events{/privacy}","received_events_url":"https://api.github.com/users/farizrahman4u/received_events","type":"User","site_admin":false},"body":"\r\n","created_at":"2018-08-30T07:38:08Z","updated_at":"2018-08-31T17:20:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"910e95ecdba1b9de6b8263c60111023510964da2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/keras-team/keras/pulls/11030/commits","review_comments_url":"https://api.github.com/repos/keras-team/keras/pulls/11030/comments","review_comment_url":"https://api.github.com/repos/keras-team/keras/pulls/comments{/number}","comments_url":"https://api.github.com/repos/keras-team/keras/issues/11030/comments","statuses_url":"https://api.github.com/repos/keras-team/keras/statuses/0a8430c03b3b7db09ce87a965b1ca49652666fb0","head":{"label":"farizrahman4u:pickle2","ref":"pickle2","sha":"0a8430c03b3b7db09ce87a965b1ca49652666fb0","user":{"login":"farizrahman4u","id":11006006,"node_id":"MDQ6VXNlcjExMDA2MDA2","avatar_url":"https://avatars0.githubusercontent.com/u/11006006?v=4","gravatar_id":"","url":"https://api.github.com/users/farizrahman4u","html_url":"https://github.com/farizrahman4u","followers_url":"https://api.github.com/users/farizrahman4u/followers","following_url":"https://api.github.com/users/farizrahman4u/following{/other_user}","gists_url":"https://api.github.com/users/farizrahman4u/gists{/gist_id}","starred_url":"https://api.github.com/users/farizrahman4u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/farizrahman4u/subscriptions","organizations_url":"https://api.github.com/users/farizrahman4u/orgs","repos_url":"https://api.github.com/users/farizrahman4u/repos","events_url":"https://api.github.com/users/farizrahman4u/events{/privacy}","received_events_url":"https://api.github.com/users/farizrahman4u/received_events","type":"User","site_admin":false},"repo":{"id":43111890,"node_id":"MDEwOlJlcG9zaXRvcnk0MzExMTg5MA==","name":"keras","full_name":"farizrahman4u/keras","owner":{"login":"farizrahman4u","id":11006006,"node_id":"MDQ6VXNlcjExMDA2MDA2","avatar_url":"https://avatars0.githubusercontent.com/u/11006006?v=4","gravatar_id":"","url":"https://api.github.com/users/farizrahman4u","html_url":"https://github.com/farizrahman4u","followers_url":"https://api.github.com/users/farizrahman4u/followers","following_url":"https://api.github.com/users/farizrahman4u/following{/other_user}","gists_url":"https://api.github.com/users/farizrahman4u/gists{/gist_id}","starred_url":"https://api.github.com/users/farizrahman4u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/farizrahman4u/subscriptions","organizations_url":"https://api.github.com/users/farizrahman4u/orgs","repos_url":"https://api.github.com/users/farizrahman4u/repos","events_url":"https://api.github.com/users/farizrahman4u/events{/privacy}","received_events_url":"https://api.github.com/users/farizrahman4u/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/farizrahman4u/keras","description":"Theano-based Deep Learning library (convnets, recurrent neural networks, and more).","fork":true,"url":"https://api.github.com/repos/farizrahman4u/keras","forks_url":"https://api.github.com/repos/farizrahman4u/keras/forks","keys_url":"https://api.github.com/repos/farizrahman4u/keras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/farizrahman4u/keras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/farizrahman4u/keras/teams","hooks_url":"https://api.github.com/repos/farizrahman4u/keras/hooks","issue_events_url":"https://api.github.com/repos/farizrahman4u/keras/issues/events{/number}","events_url":"https://api.github.com/repos/farizrahman4u/keras/events","assignees_url":"https://api.github.com/repos/farizrahman4u/keras/assignees{/user}","branches_url":"https://api.github.com/repos/farizrahman4u/keras/branches{/branch}","tags_url":"https://api.github.com/repos/farizrahman4u/keras/tags","blobs_url":"https://api.github.com/repos/farizrahman4u/keras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/farizrahman4u/keras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/farizrahman4u/keras/git/refs{/sha}","trees_url":"https://api.github.com/repos/farizrahman4u/keras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/farizrahman4u/keras/statuses/{sha}","languages_url":"https://api.github.com/repos/farizrahman4u/keras/languages","stargazers_url":"https://api.github.com/repos/farizrahman4u/keras/stargazers","contributors_url":"https://api.github.com/repos/farizrahman4u/keras/contributors","subscribers_url":"https://api.github.com/repos/farizrahman4u/keras/subscribers","subscription_url":"https://api.github.com/repos/farizrahman4u/keras/subscription","commits_url":"https://api.github.com/repos/farizrahman4u/keras/commits{/sha}","git_commits_url":"https://api.github.com/repos/farizrahman4u/keras/git/commits{/sha}","comments_url":"https://api.github.com/repos/farizrahman4u/keras/comments{/number}","issue_comment_url":"https://api.github.com/repos/farizrahman4u/keras/issues/comments{/number}","contents_url":"https://api.github.com/repos/farizrahman4u/keras/contents/{+path}","compare_url":"https://api.github.com/repos/farizrahman4u/keras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/farizrahman4u/keras/merges","archive_url":"https://api.github.com/repos/farizrahman4u/keras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/farizrahman4u/keras/downloads","issues_url":"https://api.github.com/repos/farizrahman4u/keras/issues{/number}","pulls_url":"https://api.github.com/repos/farizrahman4u/keras/pulls{/number}","milestones_url":"https://api.github.com/repos/farizrahman4u/keras/milestones{/number}","notifications_url":"https://api.github.com/repos/farizrahman4u/keras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/farizrahman4u/keras/labels{/name}","releases_url":"https://api.github.com/repos/farizrahman4u/keras/releases{/id}","deployments_url":"https://api.github.com/repos/farizrahman4u/keras/deployments","created_at":"2015-09-25T05:42:31Z","updated_at":"2018-01-20T11:02:21Z","pushed_at":"2018-08-30T16:36:20Z","git_url":"git://github.com/farizrahman4u/keras.git","ssh_url":"git@github.com:farizrahman4u/keras.git","clone_url":"https://github.com/farizrahman4u/keras.git","svn_url":"https://github.com/farizrahman4u/keras","homepage":"http://keras.io/","size":11426,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2,"open_issues":0,"watchers":6,"default_branch":"master"}},"base":{"label":"keras-team:master","ref":"master","sha":"8e8f989b850d37a4cbec7a0409343262bd963d0d","user":{"login":"keras-team","id":34455048,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0NDU1MDQ4","avatar_url":"https://avatars0.githubusercontent.com/u/34455048?v=4","gravatar_id":"","url":"https://api.github.com/users/keras-team","html_url":"https://github.com/keras-team","followers_url":"https://api.github.com/users/keras-team/followers","following_url":"https://api.github.com/users/keras-team/following{/other_user}","gists_url":"https://api.github.com/users/keras-team/gists{/gist_id}","starred_url":"https://api.github.com/users/keras-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keras-team/subscriptions","organizations_url":"https://api.github.com/users/keras-team/orgs","repos_url":"https://api.github.com/users/keras-team/repos","events_url":"https://api.github.com/users/keras-team/events{/privacy}","received_events_url":"https://api.github.com/users/keras-team/received_events","type":"Organization","site_admin":false},"repo":{"id":33015583,"node_id":"MDEwOlJlcG9zaXRvcnkzMzAxNTU4Mw==","name":"keras","full_name":"keras-team/keras","owner":{"login":"keras-team","id":34455048,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0NDU1MDQ4","avatar_url":"https://avatars0.githubusercontent.com/u/34455048?v=4","gravatar_id":"","url":"https://api.github.com/users/keras-team","html_url":"https://github.com/keras-team","followers_url":"https://api.github.com/users/keras-team/followers","following_url":"https://api.github.com/users/keras-team/following{/other_user}","gists_url":"https://api.github.com/users/keras-team/gists{/gist_id}","starred_url":"https://api.github.com/users/keras-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keras-team/subscriptions","organizations_url":"https://api.github.com/users/keras-team/orgs","repos_url":"https://api.github.com/users/keras-team/repos","events_url":"https://api.github.com/users/keras-team/events{/privacy}","received_events_url":"https://api.github.com/users/keras-team/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keras-team/keras","description":"Deep Learning for humans","fork":false,"url":"https://api.github.com/repos/keras-team/keras","forks_url":"https://api.github.com/repos/keras-team/keras/forks","keys_url":"https://api.github.com/repos/keras-team/keras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keras-team/keras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keras-team/keras/teams","hooks_url":"https://api.github.com/repos/keras-team/keras/hooks","issue_events_url":"https://api.github.com/repos/keras-team/keras/issues/events{/number}","events_url":"https://api.github.com/repos/keras-team/keras/events","assignees_url":"https://api.github.com/repos/keras-team/keras/assignees{/user}","branches_url":"https://api.github.com/repos/keras-team/keras/branches{/branch}","tags_url":"https://api.github.com/repos/keras-team/keras/tags","blobs_url":"https://api.github.com/repos/keras-team/keras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keras-team/keras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keras-team/keras/git/refs{/sha}","trees_url":"https://api.github.com/repos/keras-team/keras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keras-team/keras/statuses/{sha}","languages_url":"https://api.github.com/repos/keras-team/keras/languages","stargazers_url":"https://api.github.com/repos/keras-team/keras/stargazers","contributors_url":"https://api.github.com/repos/keras-team/keras/contributors","subscribers_url":"https://api.github.com/repos/keras-team/keras/subscribers","subscription_url":"https://api.github.com/repos/keras-team/keras/subscription","commits_url":"https://api.github.com/repos/keras-team/keras/commits{/sha}","git_commits_url":"https://api.github.com/repos/keras-team/keras/git/commits{/sha}","comments_url":"https://api.github.com/repos/keras-team/keras/comments{/number}","issue_comment_url":"https://api.github.com/repos/keras-team/keras/issues/comments{/number}","contents_url":"https://api.github.com/repos/keras-team/keras/contents/{+path}","compare_url":"https://api.github.com/repos/keras-team/keras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keras-team/keras/merges","archive_url":"https://api.github.com/repos/keras-team/keras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keras-team/keras/downloads","issues_url":"https://api.github.com/repos/keras-team/keras/issues{/number}","pulls_url":"https://api.github.com/repos/keras-team/keras/pulls{/number}","milestones_url":"https://api.github.com/repos/keras-team/keras/milestones{/number}","notifications_url":"https://api.github.com/repos/keras-team/keras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keras-team/keras/labels{/name}","releases_url":"https://api.github.com/repos/keras-team/keras/releases{/id}","deployments_url":"https://api.github.com/repos/keras-team/keras/deployments","created_at":"2015-03-28T00:35:42Z","updated_at":"2018-08-31T16:21:50Z","pushed_at":"2018-08-31T16:53:02Z","git_url":"git://github.com/keras-team/keras.git","ssh_url":"git@github.com:keras-team/keras.git","clone_url":"https://github.com/keras-team/keras.git","svn_url":"https://github.com/keras-team/keras","homepage":"http://keras.io/","size":11664,"stargazers_count":33082,"watchers_count":33082,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12448,"mirror_url":null,"archived":false,"open_issues_count":1821,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":12448,"open_issues":1821,"watchers":33082,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/keras-team/keras/pulls/11030"},"html":{"href":"https://github.com/keras-team/keras/pull/11030"},"issue":{"href":"https://api.github.com/repos/keras-team/keras/issues/11030"},"comments":{"href":"https://api.github.com/repos/keras-team/keras/issues/11030/comments"},"review_comments":{"href":"https://api.github.com/repos/keras-team/keras/pulls/11030/comments"},"review_comment":{"href":"https://api.github.com/repos/keras-team/keras/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/keras-team/keras/pulls/11030/commits"},"statuses":{"href":"https://api.github.com/repos/keras-team/keras/statuses/0a8430c03b3b7db09ce87a965b1ca49652666fb0"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"joelthchao"}}