Skip to content

Conversation

@joeyklee
Copy link
Contributor

Dear ml5 community,

I'm making a Pull Request(PR). Please see the details below.

A good PR 🌟

β†’ Step 1: Which branch are you submitting to? 🌲

Development (for new features or updates), Release (for bug fixes), or ___________?

  • nn-refactor

β†’ Step 2: Describe your Pull Request πŸ“

Fixing a Bug? Adding an Update? Submitting a New Feature? Does it introduce a breaking change?

  • Adds and update

Updates:

  • supports multilayer neural networks
  • supports conv nn architecture
  • cleans up code base

A great PR 🌟🌟

β†’ Step 3: Share a Relevant Example πŸ¦„

Here's some example code or a link to another PR in https://github.com/ml5js/ml5-examples OR in the https://editor.p5js.org or codepen/jsfiddle/etc...

Copy link
Member

@shiffman shiffman left a comment

Choose a reason for hiding this comment

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

This looks wonderful, thank you @joeyklee! I just scanned it over and I think the refactoring is all in the right direction. I commented on some minor nitpicky things in the corresponding ml5-examples pull request. I am going to make a new pose classifier example tomorrow so can test this out with it then!

@joeyklee
Copy link
Contributor Author

joeyklee commented Dec 11, 2019

A few issues popping up:

  • normalization issues with calculating min and max of large arrays (e.g. for images) causes issues - currently resolved using:
getMin(_array) {
    // return Math.min(..._array)
    return _array.reduce((a, b) => {
      return Math.min(a, b);
    });
  }
  • see line 852 in index // TODO: check to make sure this property is not static!!!!
    const {min, max} = meta.inputs.image // [headers[0]];

@joeyklee
Copy link
Contributor Author

@shiffman I will merge this in now and plan to do subsequent assessments of the updates and refactoring. There's def. some optimizations that can be made, but I think it is structurally more stable than before as well as has the beginnings of a balanced "constrained flexibility" to do enough but not too much/everything.

I'm excited to see what happens!

@joeyklee joeyklee merged commit f749d4e into development Dec 12, 2019
@joeyklee joeyklee deleted the nn-refactor-nndata-and-index branch December 12, 2019 16:57
joeyklee added a commit that referenced this pull request Jan 5, 2020
* [nn-refactor] Refactor and reimplementation of NeuralNetwork (#749)

* adds temp DiyNeuralNetwork - refactoring NeuralNetwork class

* adds updates to refactor

* refactoring nn-refactor

* adds features for compile and add layers

* rm console log

* adds train interface

* adds basic predict

* adds blank functions in data class

* update nn class

* adds nn compile handling

* updates function name

* adds data loading functions // todo - clean up

* add recursive findEntries function and data loading functions

* adds formatRawData function

* adds .addData() function

* adds saveData function

* adds handling for onehot and counting input and output units
"
"

* adds code comments

* adds concat to this.meta

* changed name to createMetaDataFromData"

* adds convertRawToTensors

* adds functions for calculating stats

* adds normalization and conversion to tensor handling

* adds .summarizeData

* adds data handling to index

* updates summarizeData function to explicitly set meta

* updates and adds functions

* updates predict function

* adds classify() with meta

* adds metadata handling and data functions

* adds loadData with options in init

* adds major updates to initiation and defaults

* adds boolean flags to check status to configure nn

* adds addData function to index

* adds support for auto labeling inputs and outputs for blank nn

* code cleanup and function name change

* flattens array in cnvertRawToTensors

* flattens inputs

* flatten array always

* adds isOneHotEncodedOrNormalized

* updates predict and classify functions and output format

* updates param handling in predict and classify

* code cleanup

* adds save function

* code cleanup

* adds first pass at loading data

* fixes missing isNormalized flag in meta

* moves loading functions to respective class

* moves files to NeuralNetwork

* moves files to NeuralNetwork and rm diyNN

* rms console.log

* check if metadata and warmedup are true before normalization

* adds unnormalize function to nn predict

* return unNormalized value

* adds loadData() and changes to loadDataFromUrl

* adds saveData to index

* adds modelUrl to constructor options in index

* cleans up predict and classify

* fix reference to unNormalizeValue

* code cleanup

* adds looping to format data for prediction and predictMultiple and classifyMultiple

* adds layer handling for options

* adds tfvis to index and ml5 root

* adds debug flag in options

* adds vis and fixes input formatting"
"

* adds model summary

* adds comments and reorders code

* refactoring functions with 3 datatypes in mind: number, string, array

* adds data handling updates

* adds handling tensors

* adds process up to training

* fixes breaking training

* adds full working poc

* fix addData check

* adds updates to api and notes to fix with functions

* adds createMetadata in index

* adds image handling in classify functino

* adds method to not exceed call stack of min and max

* fixes loadData issue

* adds first header name for min and max

* code cleanup

* removes unused functions

* fixes setDataRaw

* code clean up, organization, and adds method binding to constructor

* adds methods to constructor, adds comments, and cleans up

* adds methods to constructor for nndata

* adds methods to constructor, code cleanup, and organization

* docs: add RaisinTen as a contributor (#751)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* [neural network] adds first tests for neural network and placeholders (#755)

* initial commit for nn test

* sets karma testing random to false

* adds tests for neuralnetwork class

* adds placeholders for tests to do

* docs: add LudwigStumpp as a contributor (#758)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(Docsify Configuration (docs/index.html)): Use Docsify's auto2top property to reset scroll positi (#761)

* docs(feature-extractor.md): Switch the links for regression and classifications p5 editor examples i (#762)

* docs: add bomanimc as a contributor (#763)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Joey Lee <[email protected]>

* fix: typo

Co-authored-by: Joey Lee <[email protected]>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Bomani Oseni McClendon <[email protected]>
bomanimc added a commit that referenced this pull request Mar 12, 2020
* [nn-refactor] Refactor and reimplementation of NeuralNetwork (#749)

* adds temp DiyNeuralNetwork - refactoring NeuralNetwork class

* adds updates to refactor

* refactoring nn-refactor

* adds features for compile and add layers

* rm console log

* adds train interface

* adds basic predict

* adds blank functions in data class

* update nn class

* adds nn compile handling

* updates function name

* adds data loading functions // todo - clean up

* add recursive findEntries function and data loading functions

* adds formatRawData function

* adds .addData() function

* adds saveData function

* adds handling for onehot and counting input and output units
"
"

* adds code comments

* adds concat to this.meta

* changed name to createMetaDataFromData"

* adds convertRawToTensors

* adds functions for calculating stats

* adds normalization and conversion to tensor handling

* adds .summarizeData

* adds data handling to index

* updates summarizeData function to explicitly set meta

* updates and adds functions

* updates predict function

* adds classify() with meta

* adds metadata handling and data functions

* adds loadData with options in init

* adds major updates to initiation and defaults

* adds boolean flags to check status to configure nn

* adds addData function to index

* adds support for auto labeling inputs and outputs for blank nn

* code cleanup and function name change

* flattens array in cnvertRawToTensors

* flattens inputs

* flatten array always

* adds isOneHotEncodedOrNormalized

* updates predict and classify functions and output format

* updates param handling in predict and classify

* code cleanup

* adds save function

* code cleanup

* adds first pass at loading data

* fixes missing isNormalized flag in meta

* moves loading functions to respective class

* moves files to NeuralNetwork

* moves files to NeuralNetwork and rm diyNN

* rms console.log

* check if metadata and warmedup are true before normalization

* adds unnormalize function to nn predict

* return unNormalized value

* adds loadData() and changes to loadDataFromUrl

* adds saveData to index

* adds modelUrl to constructor options in index

* cleans up predict and classify

* fix reference to unNormalizeValue

* code cleanup

* adds looping to format data for prediction and predictMultiple and classifyMultiple

* adds layer handling for options

* adds tfvis to index and ml5 root

* adds debug flag in options

* adds vis and fixes input formatting"
"

* adds model summary

* adds comments and reorders code

* refactoring functions with 3 datatypes in mind: number, string, array

* adds data handling updates

* adds handling tensors

* adds process up to training

* fixes breaking training

* adds full working poc

* fix addData check

* adds updates to api and notes to fix with functions

* adds createMetadata in index

* adds image handling in classify functino

* adds method to not exceed call stack of min and max

* fixes loadData issue

* adds first header name for min and max

* code cleanup

* removes unused functions

* fixes setDataRaw

* code clean up, organization, and adds method binding to constructor

* adds methods to constructor, adds comments, and cleans up

* adds methods to constructor for nndata

* adds methods to constructor, code cleanup, and organization

* docs: add RaisinTen as a contributor (#751)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* [neural network] adds first tests for neural network and placeholders (#755)

* initial commit for nn test

* sets karma testing random to false

* adds tests for neuralnetwork class

* adds placeholders for tests to do

* docs: add LudwigStumpp as a contributor (#758)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(Docsify Configuration (docs/index.html)): Use Docsify's auto2top property to reset scroll positi (#761)

* docs(feature-extractor.md): Switch the links for regression and classifications p5 editor examples i (#762)

* docs: add bomanimc as a contributor (#763)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Joey Lee <[email protected]>

* fix: typo

Co-authored-by: Joey Lee <[email protected]>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Bomani Oseni McClendon <[email protected]>
bomanimc added a commit that referenced this pull request Mar 12, 2020
* [nn-refactor] Refactor and reimplementation of NeuralNetwork (#749)

* adds temp DiyNeuralNetwork - refactoring NeuralNetwork class

* adds updates to refactor

* refactoring nn-refactor

* adds features for compile and add layers

* rm console log

* adds train interface

* adds basic predict

* adds blank functions in data class

* update nn class

* adds nn compile handling

* updates function name

* adds data loading functions // todo - clean up

* add recursive findEntries function and data loading functions

* adds formatRawData function

* adds .addData() function

* adds saveData function

* adds handling for onehot and counting input and output units
"
"

* adds code comments

* adds concat to this.meta

* changed name to createMetaDataFromData"

* adds convertRawToTensors

* adds functions for calculating stats

* adds normalization and conversion to tensor handling

* adds .summarizeData

* adds data handling to index

* updates summarizeData function to explicitly set meta

* updates and adds functions

* updates predict function

* adds classify() with meta

* adds metadata handling and data functions

* adds loadData with options in init

* adds major updates to initiation and defaults

* adds boolean flags to check status to configure nn

* adds addData function to index

* adds support for auto labeling inputs and outputs for blank nn

* code cleanup and function name change

* flattens array in cnvertRawToTensors

* flattens inputs

* flatten array always

* adds isOneHotEncodedOrNormalized

* updates predict and classify functions and output format

* updates param handling in predict and classify

* code cleanup

* adds save function

* code cleanup

* adds first pass at loading data

* fixes missing isNormalized flag in meta

* moves loading functions to respective class

* moves files to NeuralNetwork

* moves files to NeuralNetwork and rm diyNN

* rms console.log

* check if metadata and warmedup are true before normalization

* adds unnormalize function to nn predict

* return unNormalized value

* adds loadData() and changes to loadDataFromUrl

* adds saveData to index

* adds modelUrl to constructor options in index

* cleans up predict and classify

* fix reference to unNormalizeValue

* code cleanup

* adds looping to format data for prediction and predictMultiple and classifyMultiple

* adds layer handling for options

* adds tfvis to index and ml5 root

* adds debug flag in options

* adds vis and fixes input formatting"
"

* adds model summary

* adds comments and reorders code

* refactoring functions with 3 datatypes in mind: number, string, array

* adds data handling updates

* adds handling tensors

* adds process up to training

* fixes breaking training

* adds full working poc

* fix addData check

* adds updates to api and notes to fix with functions

* adds createMetadata in index

* adds image handling in classify functino

* adds method to not exceed call stack of min and max

* fixes loadData issue

* adds first header name for min and max

* code cleanup

* removes unused functions

* fixes setDataRaw

* code clean up, organization, and adds method binding to constructor

* adds methods to constructor, adds comments, and cleans up

* adds methods to constructor for nndata

* adds methods to constructor, code cleanup, and organization

* docs: add RaisinTen as a contributor (#751)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* [neural network] adds first tests for neural network and placeholders (#755)

* initial commit for nn test

* sets karma testing random to false

* adds tests for neuralnetwork class

* adds placeholders for tests to do

* docs: add LudwigStumpp as a contributor (#758)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(Docsify Configuration (docs/index.html)): Use Docsify's auto2top property to reset scroll positi (#761)

* docs(feature-extractor.md): Switch the links for regression and classifications p5 editor examples i (#762)

* docs: add bomanimc as a contributor (#763)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: Joey Lee <[email protected]>

* fix: typo

Co-authored-by: Joey Lee <[email protected]>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Bomani Oseni McClendon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants