{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tfjs/issues/685","repository_url":"https://api.github.com/repos/tensorflow/tfjs","labels_url":"https://api.github.com/repos/tensorflow/tfjs/issues/685/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tfjs/issues/685/comments","events_url":"https://api.github.com/repos/tensorflow/tfjs/issues/685/events","html_url":"https://github.com/tensorflow/tfjs/issues/685","id":357750087,"node_id":"MDU6SXNzdWUzNTc3NTAwODc=","number":685,"title":"Polynomial regression : parameter isn't updating","user":{"login":"johhnry","id":35373357,"node_id":"MDQ6VXNlcjM1MzczMzU3","avatar_url":"https://avatars1.githubusercontent.com/u/35373357?v=4","gravatar_id":"","url":"https://api.github.com/users/johhnry","html_url":"https://github.com/johhnry","followers_url":"https://api.github.com/users/johhnry/followers","following_url":"https://api.github.com/users/johhnry/following{/other_user}","gists_url":"https://api.github.com/users/johhnry/gists{/gist_id}","starred_url":"https://api.github.com/users/johhnry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johhnry/subscriptions","organizations_url":"https://api.github.com/users/johhnry/orgs","repos_url":"https://api.github.com/users/johhnry/repos","events_url":"https://api.github.com/users/johhnry/events{/privacy}","received_events_url":"https://api.github.com/users/johhnry/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-06T17:18:36Z","updated_at":"2018-09-06T23:31:21Z","closed_at":null,"author_association":"NONE","body":"To get help from the community, check out our [Google group](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs).\r\n\r\n#### TensorFlow.js version\r\n0.12.5\r\n#### Browser version\r\nGoogle Chrome v68.0.3440.106\r\n#### Describe the problem or feature request\r\nHey guys,\r\n\r\nI am doing a really simple polynomial regression (inspired from this tutorial : https://www.youtube.com/watch?v=tIXDik5SGsI) and I have this problem : the c coefficient is not updated at the end of the training. I am using an adam optimizer and I really don't know what's going on.\r\n\r\n#### Code to reproduce the bug / link to feature request\r\nHere is my code : \r\n\r\n```js\r\nlet xcoords = [] , ycoords = [];\r\nconst learningRate = 0.5;\r\nconst optimizer = tf.train.adam(learningRate);\r\n\r\n//Tensors declaration\r\nlet a = tf.variable(tf.scalar(Math.random()));\r\nlet b = tf.variable(tf.scalar(Math.random()));\r\nlet c = tf.variable(tf.scalar(Math.random()));\r\n\r\n//Coordinates initialization\r\nfor(let i=0;i<10;i++){\r\n\txcoords.push(Math.random());\r\n\tycoords.push(Math.random());\r\n}\r\n\r\n//Optimize the parameters\r\na.print();\r\nb.print();\r\nc.print();\r\n\r\nfor(let iteration = 0;iteration<100;iteration++){\r\n\ttf.tidy(() => {\r\n\t\t if (xcoords.length > 0) optimizer.minimize(() => loss(predict(xcoords), ycoords));\r\n\t});\r\n}\r\nconsole.log(\"TRAINING...\");\r\na.print();\r\nb.print();\r\nc.print();\r\n\r\nfunction predict(xs) {\r\n    return tf.add(tf.tensor1d(xs).square().mul(a), tf.tensor1d(xs).mul(b), c);\r\n}\r\n\r\nfunction loss(pred, labels) {\r\n    return pred.sub(tf.tensor1d(labels)).square().mean();\r\n}\r\n```\r\n\r\n![image](https://user-images.githubusercontent.com/35373357/45173929-d3a42580-b209-11e8-9fe9-03226e9bb4da.png)\r\n\r\n\r\nThanks for helping me\r\n\r\nJoseph\r\n"},"comment":{"url":"https://api.github.com/repos/tensorflow/tfjs/issues/comments/419274021","html_url":"https://github.com/tensorflow/tfjs/issues/685#issuecomment-419274021","issue_url":"https://api.github.com/repos/tensorflow/tfjs/issues/685","id":419274021,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTI3NDAyMQ==","user":{"login":"tafsiri","id":26408,"node_id":"MDQ6VXNlcjI2NDA4","avatar_url":"https://avatars1.githubusercontent.com/u/26408?v=4","gravatar_id":"","url":"https://api.github.com/users/tafsiri","html_url":"https://github.com/tafsiri","followers_url":"https://api.github.com/users/tafsiri/followers","following_url":"https://api.github.com/users/tafsiri/following{/other_user}","gists_url":"https://api.github.com/users/tafsiri/gists{/gist_id}","starred_url":"https://api.github.com/users/tafsiri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tafsiri/subscriptions","organizations_url":"https://api.github.com/users/tafsiri/orgs","repos_url":"https://api.github.com/users/tafsiri/repos","events_url":"https://api.github.com/users/tafsiri/events{/privacy}","received_events_url":"https://api.github.com/users/tafsiri/received_events","type":"User","site_admin":false},"created_at":"2018-09-06T23:31:21Z","updated_at":"2018-09-06T23:31:21Z","author_association":"MEMBER","body":"@johhnry I believe the issue is that in your `predict` function you are passing three arguments to `tf.add` when it expects only two. The third argument, c is ignored. \r\n\r\nTry\r\n\r\n```\r\ntf.add(tf.tensor1d(xs).square().mul(a), tf.tensor1d(xs).mul(b)).add(c);\r\n```"}}
{"actor":{"display_login":"tafsiri"}}