{"action":"created","comment":{"url":"https://api.github.com/repos/tensorflow/models/pulls/comments/203848207","pull_request_review_id":138810889,"id":203848207,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMzg0ODIwNw==","diff_hunk":"@@ -609,6 +646,217 @@\n       \"execution_count\": 0,\n       \"outputs\": []\n     },\n+    {\n+      \"metadata\": {\n+        \"id\": \"XY4UspHmZNdL\",\n+        \"colab_type\": \"text\"\n+      },\n+      \"cell_type\": \"markdown\",\n+      \"source\": [\n+        \"## Interoperation with `tf.Keras`\\n\",\n+        \"\\n\",\n+        \"Now that you've seen the basics, let's build some real model components with autograph.\\n\",\n+        \"\\n\",\n+        \"It's relatively simple to integrate `autograph` with `tf.keras`. But remember that batchng is essential for performance. So the best candidate code for conversion to autograph is code where the control flow is decided at the _batch_ level. If decisions are made at the individual _example_ level you will still need to index and batch your examples to maintain performance while appling the control flow logic. \\n\",\n+        \"\\n\",\n+        \"\\n\",\n+        \"### Stateless functions\\n\",\n+        \"\\n\",\n+        \"For stateless functions like `collatz`, below, the easiest way to include them in a keras model is to wrap them up as a layer uisng `tf.keras.layers.Lambda`.\"\n+      ]\n+    },\n+    {\n+      \"metadata\": {\n+        \"id\": \"ChZh3q-zcF6C\",\n+        \"colab_type\": \"code\",\n+        \"colab\": {}\n+      },\n+      \"cell_type\": \"code\",\n+      \"source\": [\n+        \"import numpy as np\\n\",\n+        \"\\n\",\n+        \"@autograph.convert()\\n\",\n+        \"def collatz(x):\\n\",\n+        \"  x=tf.reshape(x,())\\n\",\n+        \"  assert x>0\\n\",\n+        \"  n = tf.convert_to_tensor((0,)) \\n\",\n+        \"  while not tf.equal(x,1):\\n\",\n+        \"    n+=1\\n\",\n+        \"    if tf.equal(x%2, 0):\\n\",\n+        \"      x = x//2\\n\",\n+        \"    else:\\n\",\n+        \"      x = 3*x+1\\n\",\n+        \"      \\n\",\n+        \"  return n\\n\",\n+        \"\\n\",\n+        \"with tf.Graph().as_default():\\n\",\n+        \"  model = tf.keras.Sequential([\\n\",\n+        \"    tf.keras.layers.Lambda(collatz, input_shape=(1,), output_shape=(), )\\n\",\n+        \"  ])\\n\",\n+        \"  \\n\",\n+        \"result = model.predict(np.array([6171])) #261\\n\",\n+        \"result\"\n+      ],\n+      \"execution_count\": 0,\n+      \"outputs\": []\n+    },\n+    {\n+      \"metadata\": {\n+        \"id\": \"k9LEoa3ud9hA\",\n+        \"colab_type\": \"text\"\n+      },\n+      \"cell_type\": \"markdown\",\n+      \"source\": [\n+        \"### Custom Layers and Models\\n\",\n+        \"\\n\",\n+        \"<!--TODO(markdaoust) link to full examples  or these referenced models.-->\\n\",","path":"samples/core/guide/autograph.ipynb","position":334,"original_position":334,"commit_id":"f452ab3661dc2b3b9f372a6e7f25f400fe24c930","original_commit_id":"f452ab3661dc2b3b9f372a6e7f25f400fe24c930","user":{"login":"MarkDaoust","id":1414837,"node_id":"MDQ6VXNlcjE0MTQ4Mzc=","avatar_url":"https://avatars1.githubusercontent.com/u/1414837?v=4","gravatar_id":"","url":"https://api.github.com/users/MarkDaoust","html_url":"https://github.com/MarkDaoust","followers_url":"https://api.github.com/users/MarkDaoust/followers","following_url":"https://api.github.com/users/MarkDaoust/following{/other_user}","gists_url":"https://api.github.com/users/MarkDaoust/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkDaoust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkDaoust/subscriptions","organizations_url":"https://api.github.com/users/MarkDaoust/orgs","repos_url":"https://api.github.com/users/MarkDaoust/repos","events_url":"https://api.github.com/users/MarkDaoust/events{/privacy}","received_events_url":"https://api.github.com/users/MarkDaoust/received_events","type":"User","site_admin":false},"body":"When I can show that this performs as the paper: https://colab.research.google.com/drive/14YkY78YjBhqyKn9pQ50rC36hWkuWHFb7#scrollTo=nzst0_CH2uXV","created_at":"2018-07-19T19:42:50Z","updated_at":"2018-07-19T19:52:39Z","html_url":"https://github.com/tensorflow/models/pull/4839#discussion_r203848207","pull_request_url":"https://api.github.com/repos/tensorflow/models/pulls/4839","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/tensorflow/models/pulls/comments/203848207"},"html":{"href":"https://github.com/tensorflow/models/pull/4839#discussion_r203848207"},"pull_request":{"href":"https://api.github.com/repos/tensorflow/models/pulls/4839"}},"in_reply_to_id":203800703},"pull_request":{"url":"https://api.github.com/repos/tensorflow/models/pulls/4839","id":202616340,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyNjE2MzQw","html_url":"https://github.com/tensorflow/models/pull/4839","diff_url":"https://github.com/tensorflow/models/pull/4839.diff","patch_url":"https://github.com/tensorflow/models/pull/4839.patch","issue_url":"https://api.github.com/repos/tensorflow/models/issues/4839","number":4839,"state":"open","locked":false,"title":"Add autograph keras layers example","user":{"login":"MarkDaoust","id":1414837,"node_id":"MDQ6VXNlcjE0MTQ4Mzc=","avatar_url":"https://avatars1.githubusercontent.com/u/1414837?v=4","gravatar_id":"","url":"https://api.github.com/users/MarkDaoust","html_url":"https://github.com/MarkDaoust","followers_url":"https://api.github.com/users/MarkDaoust/followers","following_url":"https://api.github.com/users/MarkDaoust/following{/other_user}","gists_url":"https://api.github.com/users/MarkDaoust/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkDaoust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkDaoust/subscriptions","organizations_url":"https://api.github.com/users/MarkDaoust/orgs","repos_url":"https://api.github.com/users/MarkDaoust/repos","events_url":"https://api.github.com/users/MarkDaoust/events{/privacy}","received_events_url":"https://api.github.com/users/MarkDaoust/received_events","type":"User","site_admin":false},"body":"+ Use meaningful function names\r\n\r\nColab link to this PR:\r\n\r\nhttps://colab.research.google.com/github/markdaoust/models/blob/autograph/samples/core/guide/autograph.ipynb","created_at":"2018-07-19T16:27:17Z","updated_at":"2018-07-19T19:52:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f58f61b4cd23f97ae22566351b4ddddc7ac43e0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":337864321,"node_id":"MDU6TGFiZWwzMzc4NjQzMjE=","url":"https://api.github.com/repos/tensorflow/models/labels/cla:%20yes","name":"cla: yes","color":"009800","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/tensorflow/models/pulls/4839/commits","review_comments_url":"https://api.github.com/repos/tensorflow/models/pulls/4839/comments","review_comment_url":"https://api.github.com/repos/tensorflow/models/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tensorflow/models/issues/4839/comments","statuses_url":"https://api.github.com/repos/tensorflow/models/statuses/f452ab3661dc2b3b9f372a6e7f25f400fe24c930","head":{"label":"MarkDaoust:autograph","ref":"autograph","sha":"f452ab3661dc2b3b9f372a6e7f25f400fe24c930","user":{"login":"MarkDaoust","id":1414837,"node_id":"MDQ6VXNlcjE0MTQ4Mzc=","avatar_url":"https://avatars1.githubusercontent.com/u/1414837?v=4","gravatar_id":"","url":"https://api.github.com/users/MarkDaoust","html_url":"https://github.com/MarkDaoust","followers_url":"https://api.github.com/users/MarkDaoust/followers","following_url":"https://api.github.com/users/MarkDaoust/following{/other_user}","gists_url":"https://api.github.com/users/MarkDaoust/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkDaoust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkDaoust/subscriptions","organizations_url":"https://api.github.com/users/MarkDaoust/orgs","repos_url":"https://api.github.com/users/MarkDaoust/repos","events_url":"https://api.github.com/users/MarkDaoust/events{/privacy}","received_events_url":"https://api.github.com/users/MarkDaoust/received_events","type":"User","site_admin":false},"repo":{"id":107041762,"node_id":"MDEwOlJlcG9zaXRvcnkxMDcwNDE3NjI=","name":"models","full_name":"MarkDaoust/models","owner":{"login":"MarkDaoust","id":1414837,"node_id":"MDQ6VXNlcjE0MTQ4Mzc=","avatar_url":"https://avatars1.githubusercontent.com/u/1414837?v=4","gravatar_id":"","url":"https://api.github.com/users/MarkDaoust","html_url":"https://github.com/MarkDaoust","followers_url":"https://api.github.com/users/MarkDaoust/followers","following_url":"https://api.github.com/users/MarkDaoust/following{/other_user}","gists_url":"https://api.github.com/users/MarkDaoust/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkDaoust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkDaoust/subscriptions","organizations_url":"https://api.github.com/users/MarkDaoust/orgs","repos_url":"https://api.github.com/users/MarkDaoust/repos","events_url":"https://api.github.com/users/MarkDaoust/events{/privacy}","received_events_url":"https://api.github.com/users/MarkDaoust/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MarkDaoust/models","description":"Models built with TensorFlow","fork":true,"url":"https://api.github.com/repos/MarkDaoust/models","forks_url":"https://api.github.com/repos/MarkDaoust/models/forks","keys_url":"https://api.github.com/repos/MarkDaoust/models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MarkDaoust/models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MarkDaoust/models/teams","hooks_url":"https://api.github.com/repos/MarkDaoust/models/hooks","issue_events_url":"https://api.github.com/repos/MarkDaoust/models/issues/events{/number}","events_url":"https://api.github.com/repos/MarkDaoust/models/events","assignees_url":"https://api.github.com/repos/MarkDaoust/models/assignees{/user}","branches_url":"https://api.github.com/repos/MarkDaoust/models/branches{/branch}","tags_url":"https://api.github.com/repos/MarkDaoust/models/tags","blobs_url":"https://api.github.com/repos/MarkDaoust/models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MarkDaoust/models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MarkDaoust/models/git/refs{/sha}","trees_url":"https://api.github.com/repos/MarkDaoust/models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MarkDaoust/models/statuses/{sha}","languages_url":"https://api.github.com/repos/MarkDaoust/models/languages","stargazers_url":"https://api.github.com/repos/MarkDaoust/models/stargazers","contributors_url":"https://api.github.com/repos/MarkDaoust/models/contributors","subscribers_url":"https://api.github.com/repos/MarkDaoust/models/subscribers","subscription_url":"https://api.github.com/repos/MarkDaoust/models/subscription","commits_url":"https://api.github.com/repos/MarkDaoust/models/commits{/sha}","git_commits_url":"https://api.github.com/repos/MarkDaoust/models/git/commits{/sha}","comments_url":"https://api.github.com/repos/MarkDaoust/models/comments{/number}","issue_comment_url":"https://api.github.com/repos/MarkDaoust/models/issues/comments{/number}","contents_url":"https://api.github.com/repos/MarkDaoust/models/contents/{+path}","compare_url":"https://api.github.com/repos/MarkDaoust/models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MarkDaoust/models/merges","archive_url":"https://api.github.com/repos/MarkDaoust/models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MarkDaoust/models/downloads","issues_url":"https://api.github.com/repos/MarkDaoust/models/issues{/number}","pulls_url":"https://api.github.com/repos/MarkDaoust/models/pulls{/number}","milestones_url":"https://api.github.com/repos/MarkDaoust/models/milestones{/number}","notifications_url":"https://api.github.com/repos/MarkDaoust/models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MarkDaoust/models/labels{/name}","releases_url":"https://api.github.com/repos/MarkDaoust/models/releases{/id}","deployments_url":"https://api.github.com/repos/MarkDaoust/models/deployments","created_at":"2017-10-15T19:21:39Z","updated_at":"2018-07-16T18:21:22Z","pushed_at":"2018-07-19T19:22:30Z","git_url":"git://github.com/MarkDaoust/models.git","ssh_url":"git@github.com:MarkDaoust/models.git","clone_url":"https://github.com/MarkDaoust/models.git","svn_url":"https://github.com/MarkDaoust/models","homepage":null,"size":482365,"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":"tensorflow:master","ref":"master","sha":"71c196c1c8c975592a4764784064f72470877a3b","user":{"login":"tensorflow","id":15658638,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NjU4NjM4","avatar_url":"https://avatars1.githubusercontent.com/u/15658638?v=4","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"repo":{"id":51117837,"node_id":"MDEwOlJlcG9zaXRvcnk1MTExNzgzNw==","name":"models","full_name":"tensorflow/models","owner":{"login":"tensorflow","id":15658638,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1NjU4NjM4","avatar_url":"https://avatars1.githubusercontent.com/u/15658638?v=4","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tensorflow/models","description":"Models and examples built with TensorFlow","fork":false,"url":"https://api.github.com/repos/tensorflow/models","forks_url":"https://api.github.com/repos/tensorflow/models/forks","keys_url":"https://api.github.com/repos/tensorflow/models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tensorflow/models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tensorflow/models/teams","hooks_url":"https://api.github.com/repos/tensorflow/models/hooks","issue_events_url":"https://api.github.com/repos/tensorflow/models/issues/events{/number}","events_url":"https://api.github.com/repos/tensorflow/models/events","assignees_url":"https://api.github.com/repos/tensorflow/models/assignees{/user}","branches_url":"https://api.github.com/repos/tensorflow/models/branches{/branch}","tags_url":"https://api.github.com/repos/tensorflow/models/tags","blobs_url":"https://api.github.com/repos/tensorflow/models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tensorflow/models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tensorflow/models/git/refs{/sha}","trees_url":"https://api.github.com/repos/tensorflow/models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tensorflow/models/statuses/{sha}","languages_url":"https://api.github.com/repos/tensorflow/models/languages","stargazers_url":"https://api.github.com/repos/tensorflow/models/stargazers","contributors_url":"https://api.github.com/repos/tensorflow/models/contributors","subscribers_url":"https://api.github.com/repos/tensorflow/models/subscribers","subscription_url":"https://api.github.com/repos/tensorflow/models/subscription","commits_url":"https://api.github.com/repos/tensorflow/models/commits{/sha}","git_commits_url":"https://api.github.com/repos/tensorflow/models/git/commits{/sha}","comments_url":"https://api.github.com/repos/tensorflow/models/comments{/number}","issue_comment_url":"https://api.github.com/repos/tensorflow/models/issues/comments{/number}","contents_url":"https://api.github.com/repos/tensorflow/models/contents/{+path}","compare_url":"https://api.github.com/repos/tensorflow/models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tensorflow/models/merges","archive_url":"https://api.github.com/repos/tensorflow/models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tensorflow/models/downloads","issues_url":"https://api.github.com/repos/tensorflow/models/issues{/number}","pulls_url":"https://api.github.com/repos/tensorflow/models/pulls{/number}","milestones_url":"https://api.github.com/repos/tensorflow/models/milestones{/number}","notifications_url":"https://api.github.com/repos/tensorflow/models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tensorflow/models/labels{/name}","releases_url":"https://api.github.com/repos/tensorflow/models/releases{/id}","deployments_url":"https://api.github.com/repos/tensorflow/models/deployments","created_at":"2016-02-05T01:15:20Z","updated_at":"2018-07-19T19:14:26Z","pushed_at":"2018-07-19T17:39:16Z","git_url":"git://github.com/tensorflow/models.git","ssh_url":"git@github.com:tensorflow/models.git","clone_url":"https://github.com/tensorflow/models.git","svn_url":"https://github.com/tensorflow/models","homepage":"","size":482743,"stargazers_count":38570,"watchers_count":38570,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22700,"mirror_url":null,"archived":false,"open_issues_count":1116,"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":22700,"open_issues":1116,"watchers":38570,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tensorflow/models/pulls/4839"},"html":{"href":"https://github.com/tensorflow/models/pull/4839"},"issue":{"href":"https://api.github.com/repos/tensorflow/models/issues/4839"},"comments":{"href":"https://api.github.com/repos/tensorflow/models/issues/4839/comments"},"review_comments":{"href":"https://api.github.com/repos/tensorflow/models/pulls/4839/comments"},"review_comment":{"href":"https://api.github.com/repos/tensorflow/models/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tensorflow/models/pulls/4839/commits"},"statuses":{"href":"https://api.github.com/repos/tensorflow/models/statuses/f452ab3661dc2b3b9f372a6e7f25f400fe24c930"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"MarkDaoust"}}