{"action":"created","comment":{"url":"https://api.github.com/repos/keras-team/keras/pulls/comments/185520222","pull_request_review_id":116925326,"id":185520222,"diff_hunk":"@@ -823,38 +828,113 @@ def is_indexed_slices(grad):\n \n     def on_epoch_end(self, epoch, logs=None):\n         logs = logs or {}\n-\n+        wait_time = 0.01\n         if not self.validation_data and self.histogram_freq:\n             raise ValueError('If printing histograms, validation_data must be '\n-                             'provided, and cannot be a generator.')\n+                             'provided.')\n         if self.validation_data and self.histogram_freq:\n+            is_val_gen = (hasattr(self.validation_data, 'next') or\n+                          hasattr(self.validation_data, '__next__') or\n+                          isinstance(self.validation_data, Sequence))\n             if epoch % self.histogram_freq == 0:\n+                if is_val_gen:\n+                    assert self.validation_steps is not None\n+                    is_sequence = isinstance(self.validation_data, Sequence)\n+                    if self.workers > 0:\n+                        if is_sequence:\n+                            enqueuer = OrderedEnqueuer(\n+                                self.validation_data,\n+                                use_multiprocessing=self.use_multiprocessing,\n+                                shuffle=self.shuffle)\n+                        else:\n+                            enqueuer = GeneratorEnqueuer(\n+                                self.validation_data,\n+                                use_multiprocessing=self.use_multiprocessing,\n+                                wait_time=wait_time)\n+                        enqueuer.start(workers=self.workers,\n+                                       max_queue_size=self.max_queue_size)\n+                        output_val_generator = enqueuer.get()\n+                    else:\n+                        if is_sequence:\n+                            output_val_generator = iter(self.validation_data)\n+                        else:\n+                            output_val_generator = self.validation_data\n+                    tensors = (self.model.inputs +\n+                               self.model.targets +\n+                               self.model.sample_weights)\n+                    if (self.model.uses_learning_phase and\n+                            not isinstance(K.learning_phase(), int)):\n+                        tensors += [K.learning_phase()]\n+                    i = 0\n+                    while i < self.validation_steps:\n+                        generator_output = next(output_val_generator)\n+                        if len(generator_output) == 2:\n+                            x, y = generator_output\n+                            sample_weight = None\n+                        elif len(generator_output) == 3:\n+                            x, y, sample_weight = generator_output\n+\n+                        if isinstance(x, list):\n+                            batch_size = x[0].shape[0]\n+                        elif isinstance(x, dict):\n+                            batch_size = list(x.values())[0].shape[0]\n+                        else:\n+                            batch_size = x.shape[0]\n+                        if batch_size == 0:\n+                            raise ValueError('Received an empty batch. '\n+                                             'Batches should at least contain one '\n+                                             'item.')\n+                        x, y, sample_weight = self.model._standardize_user_data(\n+                            x, y, sample_weight=sample_weight,\n+                            batch_size=batch_size)\n+                        batch_val = x + y + sample_weight\n+\n+                        if (self.model.uses_learning_phase and\n+                                not isinstance(K.learning_phase(), int)):\n+                            batch_val += [0.]\n+                        if not len(batch_val) == len(tensors):\n+                            raise ValueError('validation_data generator\\'s output '\n+                                             'length ({0}) must be the same as '\n+                                             'the sum of the lengths of the '\n+                                             'model\\'s inputs, targets and '\n+                                             'sample_weights ({1}).'\n+                                             .format(len(batch_val), len(tensors)))\n+\n+                        feed_dict = dict(zip(tensors, batch_val))\n+                        result = self.sess.run([self.merged], feed_dict=feed_dict)\n+                        summary_str = result[0]\n+                        self.writer.add_summary(summary_str, epoch)\n+                        i += 1\n+                else:\n+                    val_data = self.validation_data\n+                    tensors = (self.model.inputs +\n+                               self.model.targets +\n+                               self.model.sample_weights)\n \n-                val_data = self.validation_data\n-                tensors = (self.model.inputs +\n-                           self.model.targets +\n-                           self.model.sample_weights)\n-\n-                if self.model.uses_learning_phase:\n-                    tensors += [K.learning_phase()]\n-\n-                assert len(val_data) == len(tensors)\n-                val_size = val_data[0].shape[0]\n-                i = 0\n-                while i < val_size:\n-                    step = min(self.batch_size, val_size - i)\n                     if self.model.uses_learning_phase:\n-                        # do not slice the learning phase\n-                        batch_val = [x[i:i + step] for x in val_data[:-1]]\n-                        batch_val.append(val_data[-1])\n-                    else:\n-                        batch_val = [x[i:i + step] for x in val_data]\n-                    assert len(batch_val) == len(tensors)\n-                    feed_dict = dict(zip(tensors, batch_val))\n-                    result = self.sess.run([self.merged], feed_dict=feed_dict)\n-                    summary_str = result[0]\n-                    self.writer.add_summary(summary_str, epoch)\n-                    i += self.batch_size\n+                        tensors += [K.learning_phase()]\n+                    if not len(val_data) == len(tensors):\n+                        raise ValueError('validation_data length ({0}) must be '","path":"keras/callbacks.py","position":null,"original_position":137,"commit_id":"d736c03d98717fd70ba87b9e064dfb71cbf104e7","original_commit_id":"86e5448ff06d30bebfdf8a4781562ad6abaabd1c","user":{"login":"DavidAriel","id":8448791,"avatar_url":"https://avatars3.githubusercontent.com/u/8448791?v=4","gravatar_id":"","url":"https://api.github.com/users/DavidAriel","html_url":"https://github.com/DavidAriel","followers_url":"https://api.github.com/users/DavidAriel/followers","following_url":"https://api.github.com/users/DavidAriel/following{/other_user}","gists_url":"https://api.github.com/users/DavidAriel/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidAriel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidAriel/subscriptions","organizations_url":"https://api.github.com/users/DavidAriel/orgs","repos_url":"https://api.github.com/users/DavidAriel/repos","events_url":"https://api.github.com/users/DavidAriel/events{/privacy}","received_events_url":"https://api.github.com/users/DavidAriel/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2018-05-02T14:41:10Z","updated_at":"2018-05-02T14:41:10Z","html_url":"https://github.com/keras-team/keras/pull/9796#discussion_r185520222","pull_request_url":"https://api.github.com/repos/keras-team/keras/pulls/9796","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/keras-team/keras/pulls/comments/185520222"},"html":{"href":"https://github.com/keras-team/keras/pull/9796#discussion_r185520222"},"pull_request":{"href":"https://api.github.com/repos/keras-team/keras/pulls/9796"}},"in_reply_to_id":185494277},"pull_request":{"url":"https://api.github.com/repos/keras-team/keras/pulls/9796","id":178336878,"html_url":"https://github.com/keras-team/keras/pull/9796","diff_url":"https://github.com/keras-team/keras/pull/9796.diff","patch_url":"https://github.com/keras-team/keras/pull/9796.patch","issue_url":"https://api.github.com/repos/keras-team/keras/issues/9796","number":9796,"state":"open","locked":false,"title":"TensorBoard visualization support validation generator","user":{"login":"DavidAriel","id":8448791,"avatar_url":"https://avatars3.githubusercontent.com/u/8448791?v=4","gravatar_id":"","url":"https://api.github.com/users/DavidAriel","html_url":"https://github.com/DavidAriel","followers_url":"https://api.github.com/users/DavidAriel/followers","following_url":"https://api.github.com/users/DavidAriel/following{/other_user}","gists_url":"https://api.github.com/users/DavidAriel/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidAriel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidAriel/subscriptions","organizations_url":"https://api.github.com/users/DavidAriel/orgs","repos_url":"https://api.github.com/users/DavidAriel/repos","events_url":"https://api.github.com/users/DavidAriel/events{/privacy}","received_events_url":"https://api.github.com/users/DavidAriel/received_events","type":"User","site_admin":false},"body":"I saw closed PRs #4358 #4386 for issues #3358 and #8554 not sure why they are not merged... \r\nAdded my own fix, which is basically taking the code that handles preloaded validation data and reusing it for when a validation generator is used.","created_at":"2018-03-29T13:58:30Z","updated_at":"2018-05-02T14:41:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a42384d4a1d22b02adad31fc46d75c9d3afc2dae","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":808058525,"url":"https://api.github.com/repos/keras-team/keras/labels/Reviewers%20wanted","name":"Reviewers wanted","color":"0e8a16","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/keras-team/keras/pulls/9796/commits","review_comments_url":"https://api.github.com/repos/keras-team/keras/pulls/9796/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/9796/comments","statuses_url":"https://api.github.com/repos/keras-team/keras/statuses/d736c03d98717fd70ba87b9e064dfb71cbf104e7","head":{"label":"DavidAriel:Tensorboard_histogram_for_validation_generators","ref":"Tensorboard_histogram_for_validation_generators","sha":"d736c03d98717fd70ba87b9e064dfb71cbf104e7","user":{"login":"DavidAriel","id":8448791,"avatar_url":"https://avatars3.githubusercontent.com/u/8448791?v=4","gravatar_id":"","url":"https://api.github.com/users/DavidAriel","html_url":"https://github.com/DavidAriel","followers_url":"https://api.github.com/users/DavidAriel/followers","following_url":"https://api.github.com/users/DavidAriel/following{/other_user}","gists_url":"https://api.github.com/users/DavidAriel/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidAriel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidAriel/subscriptions","organizations_url":"https://api.github.com/users/DavidAriel/orgs","repos_url":"https://api.github.com/users/DavidAriel/repos","events_url":"https://api.github.com/users/DavidAriel/events{/privacy}","received_events_url":"https://api.github.com/users/DavidAriel/received_events","type":"User","site_admin":false},"repo":{"id":127288669,"name":"keras","full_name":"DavidAriel/keras","owner":{"login":"DavidAriel","id":8448791,"avatar_url":"https://avatars3.githubusercontent.com/u/8448791?v=4","gravatar_id":"","url":"https://api.github.com/users/DavidAriel","html_url":"https://github.com/DavidAriel","followers_url":"https://api.github.com/users/DavidAriel/followers","following_url":"https://api.github.com/users/DavidAriel/following{/other_user}","gists_url":"https://api.github.com/users/DavidAriel/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidAriel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidAriel/subscriptions","organizations_url":"https://api.github.com/users/DavidAriel/orgs","repos_url":"https://api.github.com/users/DavidAriel/repos","events_url":"https://api.github.com/users/DavidAriel/events{/privacy}","received_events_url":"https://api.github.com/users/DavidAriel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DavidAriel/keras","description":"Deep Learning for humans","fork":true,"url":"https://api.github.com/repos/DavidAriel/keras","forks_url":"https://api.github.com/repos/DavidAriel/keras/forks","keys_url":"https://api.github.com/repos/DavidAriel/keras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DavidAriel/keras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DavidAriel/keras/teams","hooks_url":"https://api.github.com/repos/DavidAriel/keras/hooks","issue_events_url":"https://api.github.com/repos/DavidAriel/keras/issues/events{/number}","events_url":"https://api.github.com/repos/DavidAriel/keras/events","assignees_url":"https://api.github.com/repos/DavidAriel/keras/assignees{/user}","branches_url":"https://api.github.com/repos/DavidAriel/keras/branches{/branch}","tags_url":"https://api.github.com/repos/DavidAriel/keras/tags","blobs_url":"https://api.github.com/repos/DavidAriel/keras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DavidAriel/keras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DavidAriel/keras/git/refs{/sha}","trees_url":"https://api.github.com/repos/DavidAriel/keras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DavidAriel/keras/statuses/{sha}","languages_url":"https://api.github.com/repos/DavidAriel/keras/languages","stargazers_url":"https://api.github.com/repos/DavidAriel/keras/stargazers","contributors_url":"https://api.github.com/repos/DavidAriel/keras/contributors","subscribers_url":"https://api.github.com/repos/DavidAriel/keras/subscribers","subscription_url":"https://api.github.com/repos/DavidAriel/keras/subscription","commits_url":"https://api.github.com/repos/DavidAriel/keras/commits{/sha}","git_commits_url":"https://api.github.com/repos/DavidAriel/keras/git/commits{/sha}","comments_url":"https://api.github.com/repos/DavidAriel/keras/comments{/number}","issue_comment_url":"https://api.github.com/repos/DavidAriel/keras/issues/comments{/number}","contents_url":"https://api.github.com/repos/DavidAriel/keras/contents/{+path}","compare_url":"https://api.github.com/repos/DavidAriel/keras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DavidAriel/keras/merges","archive_url":"https://api.github.com/repos/DavidAriel/keras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DavidAriel/keras/downloads","issues_url":"https://api.github.com/repos/DavidAriel/keras/issues{/number}","pulls_url":"https://api.github.com/repos/DavidAriel/keras/pulls{/number}","milestones_url":"https://api.github.com/repos/DavidAriel/keras/milestones{/number}","notifications_url":"https://api.github.com/repos/DavidAriel/keras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DavidAriel/keras/labels{/name}","releases_url":"https://api.github.com/repos/DavidAriel/keras/releases{/id}","deployments_url":"https://api.github.com/repos/DavidAriel/keras/deployments","created_at":"2018-03-29T12:32:07Z","updated_at":"2018-03-29T13:35:13Z","pushed_at":"2018-05-02T14:40:12Z","git_url":"git://github.com/DavidAriel/keras.git","ssh_url":"git@github.com:DavidAriel/keras.git","clone_url":"https://github.com/DavidAriel/keras.git","svn_url":"https://github.com/DavidAriel/keras","homepage":"http://keras.io/","size":11023,"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":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"keras-team:master","ref":"master","sha":"49b9682b3570211c7d8f619f8538c08fd5d8bdad","user":{"login":"keras-team","id":34455048,"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,"name":"keras","full_name":"keras-team/keras","owner":{"login":"keras-team","id":34455048,"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-05-02T14:15:23Z","pushed_at":"2018-05-02T14:40:25Z","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":11027,"stargazers_count":28911,"watchers_count":28911,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10745,"mirror_url":null,"archived":false,"open_issues_count":1410,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":10745,"open_issues":1410,"watchers":28911,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/keras-team/keras/pulls/9796"},"html":{"href":"https://github.com/keras-team/keras/pull/9796"},"issue":{"href":"https://api.github.com/repos/keras-team/keras/issues/9796"},"comments":{"href":"https://api.github.com/repos/keras-team/keras/issues/9796/comments"},"review_comments":{"href":"https://api.github.com/repos/keras-team/keras/pulls/9796/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/9796/commits"},"statuses":{"href":"https://api.github.com/repos/keras-team/keras/statuses/d736c03d98717fd70ba87b9e064dfb71cbf104e7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"DavidAriel"}}