{"action":"created","comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/comments/56587580","id":56587580,"diff_hunk":"@@ -77,10 +78,173 @@ def exponential_decay(learning_rate, global_step, decay_steps, decay_rate,\n                    name, \"ExponentialDecay\") as name:\n     learning_rate = ops.convert_to_tensor(learning_rate, name=\"learning_rate\")\n     dtype = learning_rate.dtype\n-    global_step = math_ops.cast(global_step, dtype)\n-    decay_steps = math_ops.cast(decay_steps, dtype)\n-    decay_rate = math_ops.cast(decay_rate, dtype)\n+    global_step = cast(global_step, dtype)\n+    decay_steps = cast(decay_steps, dtype)\n+    decay_rate = cast(decay_rate, dtype)\n     p = global_step / decay_steps\n     if staircase:\n-      p = math_ops.floor(p)\n-    return math_ops.mul(learning_rate, math_ops.pow(decay_rate, p), name=name)\n+      p = floor(p)\n+    return mul(learning_rate, pow(decay_rate, p), name=name)\n+\n+def exponential_time_decay(initial_lr, epoch, decay_rate, name=None):\n+  \"\"\"Applies exponential decay to the learning rate.\n+\n+  When training a model, it is often recommended to lower the learning rate as\n+  the training progresses.  This function applies an exponential decay function\n+  to a provided initial learning rate.  It requires an `epoch` to  compute the\n+  decayed learning rate.  You can just pass a TensorFlow variable that you\n+  increment at each training step.\n+\n+  The function returns the decayed learning rate.  It is computed as:\n+\n+  ```python\n+  decayed_learning_rate = initial_lr * exp(-decay_rate * epoch)\n+  ```\n+\n+  Example: decay exponetially with a base of 0.96:\n+\n+  ```python\n+  ...\n+  epoch = tf.Variable(0, trainable=False)\n+  initial_lr = 0.1\n+  decay_rate = 0.5\n+  learning_rate = tf.train.exponential_time_decay(initial_lr, epoch, k)\n+\n+  # Passing epoch to minimize() will increment it at each step.\n+  learning_step = (\n+      tf.GradientDescentOptimizer(learning_rate)\n+      .minimize(...my loss..., global_step=epoch)\n+  )\n+  ```\n+\n+  Args:\n+    initial_lr: A scalar `float32` or `float64` `Tensor` or a\n+      Python number.  The initial learning rate.\n+    epoch: A Python number.\n+      Global step to use for the decay computation.  Must not be negative.\n+    decay_rate: A Python number.  The decay rate.\n+    name: String.  Optional name of the operation.  Defaults to\n+      'ExponentialTimeDecay'\n+\n+  Returns:\n+    A scalar `Tensor` of the same type as `learning_rate`.  The decayed\n+    learning rate.\n+  \"\"\"\n+  with ops.op_scope([initial_lr, epoch, decay_rate],\n+                   name, \"ExponentialTimeDecay\") as name:\n+    initial_lr = ops.convert_to_tensor(initial_lr, name=\"learning_rate\")\n+    decay_rate = cast(decay_rate, initial_lr.dtype)\n+    exponent = exp(mul(neg(decay_rate), epoch))\n+    return mul(initial_lr, exponent, name=name)\n+","path":"tensorflow/python/training/learning_rate_decay.py","position":77,"original_position":77,"commit_id":"6d04864e44a892fb109da29654a226fe8900a7fa","original_commit_id":"6d04864e44a892fb109da29654a226fe8900a7fa","user":{"login":"vrv","id":463737,"avatar_url":"https://avatars.githubusercontent.com/u/463737?v=3","gravatar_id":"","url":"https://api.github.com/users/vrv","html_url":"https://github.com/vrv","followers_url":"https://api.github.com/users/vrv/followers","following_url":"https://api.github.com/users/vrv/following{/other_user}","gists_url":"https://api.github.com/users/vrv/gists{/gist_id}","starred_url":"https://api.github.com/users/vrv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrv/subscriptions","organizations_url":"https://api.github.com/users/vrv/orgs","repos_url":"https://api.github.com/users/vrv/repos","events_url":"https://api.github.com/users/vrv/events{/privacy}","received_events_url":"https://api.github.com/users/vrv/received_events","type":"User","site_admin":false},"body":"We use two line spaces between top-level definitions","created_at":"2016-03-17T22:22:55Z","updated_at":"2016-03-17T22:22:55Z","html_url":"https://github.com/tensorflow/tensorflow/pull/1512#discussion_r56587580","pull_request_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/1512","_links":{"self":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/comments/56587580"},"html":{"href":"https://github.com/tensorflow/tensorflow/pull/1512#discussion_r56587580"},"pull_request":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/1512"}}},"pull_request":{"url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/1512","id":62901624,"html_url":"https://github.com/tensorflow/tensorflow/pull/1512","diff_url":"https://github.com/tensorflow/tensorflow/pull/1512.diff","patch_url":"https://github.com/tensorflow/tensorflow/pull/1512.patch","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1512","number":1512,"state":"open","locked":false,"title":"some learning decays from Stanford CS261n Karpathy lecture 6","user":{"login":"chemelnucfin","id":3982092,"avatar_url":"https://avatars.githubusercontent.com/u/3982092?v=3","gravatar_id":"","url":"https://api.github.com/users/chemelnucfin","html_url":"https://github.com/chemelnucfin","followers_url":"https://api.github.com/users/chemelnucfin/followers","following_url":"https://api.github.com/users/chemelnucfin/following{/other_user}","gists_url":"https://api.github.com/users/chemelnucfin/gists{/gist_id}","starred_url":"https://api.github.com/users/chemelnucfin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chemelnucfin/subscriptions","organizations_url":"https://api.github.com/users/chemelnucfin/orgs","repos_url":"https://api.github.com/users/chemelnucfin/repos","events_url":"https://api.github.com/users/chemelnucfin/events{/privacy}","received_events_url":"https://api.github.com/users/chemelnucfin/received_events","type":"User","site_admin":false},"body":"exponential time decay\r\nstep decay\r\n1/t decay\r\nfrom Lecture 6-39 Stanford CS261n ","created_at":"2016-03-15T13:03:00Z","updated_at":"2016-03-17T22:22:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"94a24e152af55030525c277405607d4cdf33e321","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/1512/commits","review_comments_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/1512/comments","review_comment_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1512/comments","statuses_url":"https://api.github.com/repos/tensorflow/tensorflow/statuses/6d04864e44a892fb109da29654a226fe8900a7fa","head":{"label":"chemelnucfin:learning_rate","ref":"learning_rate","sha":"6d04864e44a892fb109da29654a226fe8900a7fa","user":{"login":"chemelnucfin","id":3982092,"avatar_url":"https://avatars.githubusercontent.com/u/3982092?v=3","gravatar_id":"","url":"https://api.github.com/users/chemelnucfin","html_url":"https://github.com/chemelnucfin","followers_url":"https://api.github.com/users/chemelnucfin/followers","following_url":"https://api.github.com/users/chemelnucfin/following{/other_user}","gists_url":"https://api.github.com/users/chemelnucfin/gists{/gist_id}","starred_url":"https://api.github.com/users/chemelnucfin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chemelnucfin/subscriptions","organizations_url":"https://api.github.com/users/chemelnucfin/orgs","repos_url":"https://api.github.com/users/chemelnucfin/repos","events_url":"https://api.github.com/users/chemelnucfin/events{/privacy}","received_events_url":"https://api.github.com/users/chemelnucfin/received_events","type":"User","site_admin":false},"repo":{"id":46086450,"name":"tensorflow","full_name":"chemelnucfin/tensorflow","owner":{"login":"chemelnucfin","id":3982092,"avatar_url":"https://avatars.githubusercontent.com/u/3982092?v=3","gravatar_id":"","url":"https://api.github.com/users/chemelnucfin","html_url":"https://github.com/chemelnucfin","followers_url":"https://api.github.com/users/chemelnucfin/followers","following_url":"https://api.github.com/users/chemelnucfin/following{/other_user}","gists_url":"https://api.github.com/users/chemelnucfin/gists{/gist_id}","starred_url":"https://api.github.com/users/chemelnucfin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chemelnucfin/subscriptions","organizations_url":"https://api.github.com/users/chemelnucfin/orgs","repos_url":"https://api.github.com/users/chemelnucfin/repos","events_url":"https://api.github.com/users/chemelnucfin/events{/privacy}","received_events_url":"https://api.github.com/users/chemelnucfin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chemelnucfin/tensorflow","description":" Open source software library for numerical computation using data flow graphs.","fork":true,"url":"https://api.github.com/repos/chemelnucfin/tensorflow","forks_url":"https://api.github.com/repos/chemelnucfin/tensorflow/forks","keys_url":"https://api.github.com/repos/chemelnucfin/tensorflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chemelnucfin/tensorflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chemelnucfin/tensorflow/teams","hooks_url":"https://api.github.com/repos/chemelnucfin/tensorflow/hooks","issue_events_url":"https://api.github.com/repos/chemelnucfin/tensorflow/issues/events{/number}","events_url":"https://api.github.com/repos/chemelnucfin/tensorflow/events","assignees_url":"https://api.github.com/repos/chemelnucfin/tensorflow/assignees{/user}","branches_url":"https://api.github.com/repos/chemelnucfin/tensorflow/branches{/branch}","tags_url":"https://api.github.com/repos/chemelnucfin/tensorflow/tags","blobs_url":"https://api.github.com/repos/chemelnucfin/tensorflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chemelnucfin/tensorflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chemelnucfin/tensorflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/chemelnucfin/tensorflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chemelnucfin/tensorflow/statuses/{sha}","languages_url":"https://api.github.com/repos/chemelnucfin/tensorflow/languages","stargazers_url":"https://api.github.com/repos/chemelnucfin/tensorflow/stargazers","contributors_url":"https://api.github.com/repos/chemelnucfin/tensorflow/contributors","subscribers_url":"https://api.github.com/repos/chemelnucfin/tensorflow/subscribers","subscription_url":"https://api.github.com/repos/chemelnucfin/tensorflow/subscription","commits_url":"https://api.github.com/repos/chemelnucfin/tensorflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/chemelnucfin/tensorflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/chemelnucfin/tensorflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/chemelnucfin/tensorflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/chemelnucfin/tensorflow/contents/{+path}","compare_url":"https://api.github.com/repos/chemelnucfin/tensorflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chemelnucfin/tensorflow/merges","archive_url":"https://api.github.com/repos/chemelnucfin/tensorflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chemelnucfin/tensorflow/downloads","issues_url":"https://api.github.com/repos/chemelnucfin/tensorflow/issues{/number}","pulls_url":"https://api.github.com/repos/chemelnucfin/tensorflow/pulls{/number}","milestones_url":"https://api.github.com/repos/chemelnucfin/tensorflow/milestones{/number}","notifications_url":"https://api.github.com/repos/chemelnucfin/tensorflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chemelnucfin/tensorflow/labels{/name}","releases_url":"https://api.github.com/repos/chemelnucfin/tensorflow/releases{/id}","deployments_url":"https://api.github.com/repos/chemelnucfin/tensorflow/deployments","created_at":"2015-11-12T23:05:13Z","updated_at":"2016-02-27T07:42:47Z","pushed_at":"2016-03-16T12:36:42Z","git_url":"git://github.com/chemelnucfin/tensorflow.git","ssh_url":"git@github.com:chemelnucfin/tensorflow.git","clone_url":"https://github.com/chemelnucfin/tensorflow.git","svn_url":"https://github.com/chemelnucfin/tensorflow","homepage":"http://tensorflow.org","size":78555,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tensorflow:master","ref":"master","sha":"f7a0b752131dc145191521730779e096864efc1d","user":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars.githubusercontent.com/u/15658638?v=3","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":45717250,"name":"tensorflow","full_name":"tensorflow/tensorflow","owner":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars.githubusercontent.com/u/15658638?v=3","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/tensorflow","description":"Computation using data flow graphs for scalable machine learning","fork":false,"url":"https://api.github.com/repos/tensorflow/tensorflow","forks_url":"https://api.github.com/repos/tensorflow/tensorflow/forks","keys_url":"https://api.github.com/repos/tensorflow/tensorflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tensorflow/tensorflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tensorflow/tensorflow/teams","hooks_url":"https://api.github.com/repos/tensorflow/tensorflow/hooks","issue_events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/events{/number}","events_url":"https://api.github.com/repos/tensorflow/tensorflow/events","assignees_url":"https://api.github.com/repos/tensorflow/tensorflow/assignees{/user}","branches_url":"https://api.github.com/repos/tensorflow/tensorflow/branches{/branch}","tags_url":"https://api.github.com/repos/tensorflow/tensorflow/tags","blobs_url":"https://api.github.com/repos/tensorflow/tensorflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tensorflow/tensorflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tensorflow/tensorflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/tensorflow/tensorflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tensorflow/tensorflow/statuses/{sha}","languages_url":"https://api.github.com/repos/tensorflow/tensorflow/languages","stargazers_url":"https://api.github.com/repos/tensorflow/tensorflow/stargazers","contributors_url":"https://api.github.com/repos/tensorflow/tensorflow/contributors","subscribers_url":"https://api.github.com/repos/tensorflow/tensorflow/subscribers","subscription_url":"https://api.github.com/repos/tensorflow/tensorflow/subscription","commits_url":"https://api.github.com/repos/tensorflow/tensorflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/tensorflow/tensorflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/tensorflow/tensorflow/contents/{+path}","compare_url":"https://api.github.com/repos/tensorflow/tensorflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tensorflow/tensorflow/merges","archive_url":"https://api.github.com/repos/tensorflow/tensorflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tensorflow/tensorflow/downloads","issues_url":"https://api.github.com/repos/tensorflow/tensorflow/issues{/number}","pulls_url":"https://api.github.com/repos/tensorflow/tensorflow/pulls{/number}","milestones_url":"https://api.github.com/repos/tensorflow/tensorflow/milestones{/number}","notifications_url":"https://api.github.com/repos/tensorflow/tensorflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/labels{/name}","releases_url":"https://api.github.com/repos/tensorflow/tensorflow/releases{/id}","deployments_url":"https://api.github.com/repos/tensorflow/tensorflow/deployments","created_at":"2015-11-07T01:19:20Z","updated_at":"2016-03-17T21:20:56Z","pushed_at":"2016-03-17T22:19:24Z","git_url":"git://github.com/tensorflow/tensorflow.git","ssh_url":"git@github.com:tensorflow/tensorflow.git","clone_url":"https://github.com/tensorflow/tensorflow.git","svn_url":"https://github.com/tensorflow/tensorflow","homepage":"http://tensorflow.org","size":130322,"stargazers_count":19788,"watchers_count":19788,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6876,"mirror_url":null,"open_issues_count":313,"forks":6876,"open_issues":313,"watchers":19788,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/1512"},"html":{"href":"https://github.com/tensorflow/tensorflow/pull/1512"},"issue":{"href":"https://api.github.com/repos/tensorflow/tensorflow/issues/1512"},"comments":{"href":"https://api.github.com/repos/tensorflow/tensorflow/issues/1512/comments"},"review_comments":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/1512/comments"},"review_comment":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tensorflow/tensorflow/pulls/1512/commits"},"statuses":{"href":"https://api.github.com/repos/tensorflow/tensorflow/statuses/6d04864e44a892fb109da29654a226fe8900a7fa"}}}}