As easy as I can make Tensorflowjs Keras Layers One Hot Encoding

This page is about One-Hot-Encoding. One-Hot-Encoding can be used when you have sets of information either as inputs to a neural network or as outputs.

The Problem

Tensorflowjs works with real numbers (called decimal or floating point numbers), so if your Neural Network is outputing information that is about a defined group, the neural network should give a range from that group to the next group. Say you defined your output as 1.00 = mammals, 2=reptiles, 3=birds, etc.
Your neural network might identify an animal as 1.45. Meaning somewhere between Mammals and reptiles. So what does that mean?

The Solution

With One-Hot Encoding each output becomes an object to be rated by your neural network. So you might get results such as Mammal 75%, reptile 25%, bird 15%
This style of result becomes much more useful.

The Con

One-hot encoding needs large sets of inputs of zeros with only one input set as 1! This can quickly become a very large set of input data.

This Simple example

We will train the following information:
Species Class One-Hot-Species One-Hot-Class
Elephant: Mammal 1,0,0,0,0,0,0,0 1,0,0,0
Fox: Mammal 0,1,0,0,0,0,0,0 1,0,0,0
Crow: Bird (Aves) 0,0,1,0,0,0,0,0 0,1,0,0
Aligator: Reptile 0,0,0,1,0,0,0,0 0,0,1,0
Dolphin: Mammal 0,0,0,0,1,0,0,0 1,0,0,0
Sparrow: Bird (Aves) 0,0,0,0,0,1,0,0 0,1,0,0
Turtle: Reptile 0,0,0,0,0,0,1,0 0,0,1,0
Toad: Amphibians 0,0,0,0,0,0,0,1 0,0,0,1



...











Now lets try the above in a full Machine Learning Web App

Tensorflowjs Machine Learning Web App Template

As simple as possible template. Note that for simplicity this has minimal CSS

Pre-Set Values:

Learning Rate:
Samples per batch:
Epochs: (# of batches to run)
Validation Split :



Data:

xTrainingData:
yTrainingTarget:



Compile or Load Model:

Compile, Train, Test: Import / Export
Compile Model:
Train Model: Epochs run:
Test Trained Model with New Data: New Data:CrowShape:

...

...


...











This Github, ... this Github Website Version, ... this Hosted Website Version, ... Tensorflowjs

By Jeremy Ellis
Twitter@rocksetta
Website http://rocksetta.com
Use at your own risk!