Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Conversation

@chihuahua
Copy link
Member

@chihuahua chihuahua commented Aug 7, 2017

This tutorial takes the reader through making a model to predict the complements of colors within RGB space. We make a simple feed forward network with 3 fully-connected layers.


This change is Reviewable

This tutorial takes the reader through making a model to predict the complements of colors within RGB space. We make a simple feed forward network with 3 fully-connected layers.
@@ -0,0 +1,194 @@
# Predicting Complementary Colors with deeplearn.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this file in demos/complementary-color-prediction/ - doesn't have to be in docs/tutorials. The website will pick it up and show it on the right side in https://pair-code.github.io/deeplearnjs/docs/tutorials/index.html automatically

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,136 @@
<!-- Copyright 2017 Google Inc. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run the demo using watch-demo and share the url with us? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,355 @@
/* Copyright 2017 Google Inc. All Rights Reserved.
Copy link
Contributor

@dsmilkov dsmilkov Aug 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to run npm run lint to check for lint errors. Thanks for your patience before we automate this with travis CI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this output

agent007@agent007:~/deeplearnjs$ npm run lint

deeplearn@0.1.0 lint /usr/home/agent007/deeplearnjs
tslint -p . --type-check -t verbose

ERROR: (no-any) /usr/home/agent007/deeplearnjs/demos/homepage/index.ts[30, 63]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type, the empty type ('{}'), or suppress this occurrence.
ERROR: (triple-equals) /usr/home/agent007/deeplearnjs/demos/homepage/index.ts[21, 28]: != should be !==

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! deeplearn@0.1.0 lint: tslint -p . --type-check -t verbose
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the deeplearn@0.1.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /usr/home/agent007/.npm/_logs/2017-08-09T08_43_14_372Z-debug.log

@dsmilkov
Copy link
Contributor

Reviewed 2 of 6 files at r2, 1 of 2 files at r3.
Review status: 3 of 6 files reviewed at latest revision, 7 unresolved discussions.


npm-debug.log, line 1 at r4 (raw file):

0 info it worked if it ends with ok

revert this file


demos/.DS_Store, line 0 at r4 (raw file):
revert this file also


demos/complementary-color-prediction/complementary-color-prediction.html, line 11 at r4 (raw file):

See the License for the specific language governing permissions and
limitations under the License.
==============================================================================-->

reduce last line of license to 80 width


demos/complementary-color-prediction/complementary-color-prediction.ts, line 1 at r1 (raw file):

Previously, chihuahua (Chi Zeng) wrote…

I get this output

agent007@agent007:~/deeplearnjs$ npm run lint

deeplearn@0.1.0 lint /usr/home/agent007/deeplearnjs
tslint -p . --type-check -t verbose

ERROR: (no-any) /usr/home/agent007/deeplearnjs/demos/homepage/index.ts[30, 63]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type, the empty type ('{}'), or suppress this occurrence.
ERROR: (triple-equals) /usr/home/agent007/deeplearnjs/demos/homepage/index.ts[21, 28]: != should be !==

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! deeplearn@0.1.0 lint: tslint -p . --type-check -t verbose
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the deeplearn@0.1.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /usr/home/agent007/.npm/_logs/2017-08-09T08_43_14_372Z-debug.log

Did you run npm run prep? Also can you check that you have the right version of the tsc compiler (2.3.4) by running node_modules/.bin/tsc --version?


demos/complementary-color-prediction/complementary_color_prediction.md, line 3 at r4 (raw file):

may not be perfectly optimized

maybe elaborate a bit on this. Are you thinking about hyper-params or not optimized for speed (not using the library in the best way)?

If hyper-params, you can say smth like
'We didn't spend time tuning the hyper-parameters so there is still lots of room - we'd love a pull request.'


demos/complementary-color-prediction/complementary_color_prediction.md, line 271 at r4 (raw file):

Based on a few sample colors, it seems like our model of `64 + 32 + 16 = 112` middle-layer nodes fairs alright.

TODO(chihuahua): Update this image to complementary-color-prediction.png once it is checked in.

Remove TODO and update the link now? Since it will get checked in this PR.


demos/complementary-color-prediction/complementary_color_prediction.md, line 274 at r4 (raw file):

offer

s/offer/offers/ (might be wrong, feel free to ignore)


Comments from Reviewable

@chihuahua
Copy link
Member Author

Review status: 2 of 5 files reviewed at latest revision, 7 unresolved discussions, some commit checks failed.


demos/complementary-color-prediction/complementary-color-prediction.html, line 11 at r4 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

reduce last line of license to 80 width

Done. Moved closing comment tag to the next line.


demos/complementary-color-prediction/complementary-color-prediction.ts, line 1 at r1 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

Did you run npm run prep? Also can you check that you have the right version of the tsc compiler (2.3.4) by running node_modules/.bin/tsc --version?

Indeed, version 2.3.4 ...

agent007@agent007:~/Desktop/deeplearnjs$ node_modules/.bin/tsc --version
Version 2.3.4

I did run npm run prep. I tried again and think I get the same output ... odd. Here is the output of the log file. I might have some time later to dig deeper.

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/home/agent007/.nvm/versions/node/v8.3.0/bin/node',
1 verbose cli   '/usr/local/home/agent007/.nvm/versions/node/v8.3.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'lint' ]
2 info using npm@5.3.0
3 info using node@v8.3.0
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle deeplearn@0.1.0~prelint: deeplearn@0.1.0
6 info lifecycle deeplearn@0.1.0~lint: deeplearn@0.1.0
7 verbose lifecycle deeplearn@0.1.0~lint: unsafe-perm in lifecycle true
8 verbose lifecycle deeplearn@0.1.0~lint: PATH: /usr/local/home/agent007/.nvm/versions/node/v8.3.0/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/home/agent007/Desktop/deeplearnjs/node_modules/.bin:/usr/local/home/agent007/.nvm/versions/node/v8.3.0/bin:/usr/local/home/agent007/anaconda2/bin:/usr/lib/google-golang/bin:/usr/local/buildtools/java/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/src/head/depot/google3/third_party/gpus/cuda_8_0/bin
9 verbose lifecycle deeplearn@0.1.0~lint: CWD: /usr/local/home/agent007/Desktop/deeplearnjs
10 silly lifecycle deeplearn@0.1.0~lint: Args: [ '-c', 'tslint -p . --type-check -t verbose' ]
11 silly lifecycle deeplearn@0.1.0~lint: Returned: code: 2  signal: null
12 info lifecycle deeplearn@0.1.0~lint: Failed to exec lint script
13 verbose stack Error: deeplearn@0.1.0 lint: `tslint -p . --type-check -t verbose`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/home/agent007/.nvm/versions/node/v8.3.0/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at EventEmitter.emit (events.js:213:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/home/agent007/.nvm/versions/node/v8.3.0/lib/node_modules/npm/lib/utils/spawn.js:40:14)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at ChildProcess.emit (events.js:213:7)
13 verbose stack     at maybeClose (internal/child_process.js:927:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid deeplearn@0.1.0
15 verbose cwd /usr/local/home/agent007/Desktop/deeplearnjs
16 verbose Linux 4.4.0-83-generic
17 verbose argv "/usr/local/home/agent007/.nvm/versions/node/v8.3.0/bin/node" "/usr/local/home/agent007/.nvm/versions/node/v8.3.0/bin/npm" "run" "lint"
18 verbose node v8.3.0
19 verbose npm  v5.3.0
20 error code ELIFECYCLE
21 error errno 2
22 error deeplearn@0.1.0 lint: `tslint -p . --type-check -t verbose`
22 error Exit status 2
23 error Failed at the deeplearn@0.1.0 lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

demos/complementary-color-prediction/complementary_color_prediction.md, line 3 at r4 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

may not be perfectly optimized

maybe elaborate a bit on this. Are you thinking about hyper-params or not optimized for speed (not using the library in the best way)?

If hyper-params, you can say smth like
'We didn't spend time tuning the hyper-parameters so there is still lots of room - we'd love a pull request.'

Done. Right - I meant that this tutorial did not optimize for hyperparameters (number of layers, sizes of layers). If you have any feedback on using the library better - let me know!


demos/complementary-color-prediction/complementary_color_prediction.md, line 271 at r4 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

Remove TODO and update the link now? Since it will get checked in this PR.

I removed the TODO and verified that the markdown should look correct:

RouVWhA1GDN.png

The markdown preview currently does not show the image because the URL is relative to the PAIR-code organization, and the image has not yet been checked into the PAIR-code/deeplearnjs repo yet.


demos/complementary-color-prediction/complementary_color_prediction.md, line 274 at r4 (raw file):

s within it offer a
Done.

Also, to avoid bloating this tutorial, I sort of glossed over the logic for managing the UI. That also makes the tutorial focus on deeplearn.js. Let me know if you have thoughts on that.


npm-debug.log, line 1 at r4 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

revert this file

Done.


demos/.DS_Store, line at r4 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

revert this file also

Done.


Comments from Reviewable

@dsmilkov
Copy link
Contributor

:lgtm:


Reviewed 3 of 6 files at r2, 1 of 1 files at r4, 5 of 5 files at r5.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


demos/complementary-color-prediction/complementary_color_prediction.md, line 271 at r4 (raw file):

Previously, chihuahua (Chi Zeng) wrote…

I removed the TODO and verified that the markdown should look correct:

RouVWhA1GDN.png

The markdown preview currently does not show the image because the URL is relative to the PAIR-code organization, and the image has not yet been checked into the PAIR-code/deeplearnjs repo yet.

I think you can do relative paths in markdown links, .e.g
Predicting Complementary Colors
also when linking the other articles from this article.


demos/complementary-color-prediction/complementary_color_prediction.md, line 274 at r4 (raw file):

Previously, chihuahua (Chi Zeng) wrote…

s within it offer a
Done.

Also, to avoid bloating this tutorial, I sort of glossed over the logic for managing the UI. That also makes the tutorial focus on deeplearn.js. Let me know if you have thoughts on that.

I think it's good. Short and sweet. We can get feedback from our users and improve later.


Comments from Reviewable

@chihuahua
Copy link
Member Author

Review status: 3 of 5 files reviewed at latest revision, all discussions resolved, some commit checks failed.


demos/complementary-color-prediction/complementary_color_prediction.md, line 271 at r4 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

I think you can do relative paths in markdown links, .e.g
Predicting Complementary Colors
also when linking the other articles from this article.

Indeed, relative links work! Done.


Comments from Reviewable

@chihuahua
Copy link
Member Author

I modified relative links. Feel free to merge at any time.

One problem I realized is that, sometimes, certain weight values are initialized to 0, and then those color channels just stay at 0. Like this:

usavox2kr9j

I so far lack a solution for this. Refreshing the page usually allows for normal training, but it's unfortunate that initialization of weights matters.

@chihuahua
Copy link
Member Author

chihuahua commented Aug 13, 2017

Interestingly, despite having a channel stuck at 0, the predictions are often not that bad:

blue-channel-at-0

Anyways, I added a new section in the markdown that documents this caveat.

@dsmilkov
Copy link
Contributor

Ha, that's very interesting about the weights going to 0.

Wohoo, thanks for writing this awesome tutorial!

@dsmilkov dsmilkov merged commit 123a37c into tensorflow:master Aug 13, 2017
mnottheone pushed a commit to mnottheone/deeplearnjs that referenced this pull request Dec 1, 2018
* Write a tutorial for deeplearn.js

This tutorial takes the reader through making a model to predict the complements of colors within RGB space. We make a simple feed forward network with 3 fully-connected layers.

* .

* Finish md

* Update TOC

* Update complementary_color_prediction.md

* Remove npm-debug.log and .DS_Store

Also modified .gitignore to avoid re-adding them.

* Address comments

* Change image URL

* Move comment closing tag to next line

* Make png link relative

* Remove unused imports

* Make links relative

* Describe problem of channel stuck at 0

* .

* .
GreyZzzzzzXh pushed a commit to GreyZzzzzzXh/tfjs-core that referenced this pull request May 13, 2019
[Mulmat] register flags for matmul
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants