This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
* Code for canvas drawing is shamefully stolen from this nice project below | |
* https://github.com/Gogul09/digit-recognizer-live/blob/master/js/app.js | |
*/ | |
const canvasWidth = 400; | |
const canvasHeight = 400; | |
const canvasStrokeStyle = "white"; | |
const canvasLineJoin = "round"; | |
const canvasLineWidth = 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" | |
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> | |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script> | |
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node app.js --train_mode=0 --epochs=10 --batch_size=64 --model_save_path='file:///home/personal/TensorFlowjs_Projects/mnist-classification/public/assets/model' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node app.js --train_mode=1 --epochs=10 --batch_size=64 --model_save_path='file:///home/personal/TensorFlowjs_Projects/mnist-classification/public/assets/model' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tf = require('@tensorflow/tfjs-node'); | |
const data = require('./data') | |
const IMAGE_WIDTH = 28 | |
const IMAGE_HEIGHT = 28 | |
const IMAGE_CHANNEL = 1 | |
function getModel() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tf = require('@tensorflow/tfjs-node'); | |
const BASE_PATH = "file:///home/dsn/personal/Tfjs/TensorFlowjs_Projects/mnist-classification/dataset/"; | |
const TRAIN_DATA = `${BASE_PATH}train.csv`; | |
const IMAGE_WIDTH = 28 | |
const IMAGE_HEIGHT = 28 | |
const IMAGE_CHANNEL = 1 | |
const NUM_CLASSES = 10; | |
const DATA_SIZE = 42000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mnist-classification", | |
"version": "0.0.0", | |
"private": true, | |
"scripts": { | |
"start": "node ./bin/www" | |
}, | |
"dependencies": { | |
"@tensorflow/tfjs-node": "1.7.4", | |
"argparse": "*", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const path = require('path'); | |
const cookieParser = require('cookie-parser'); | |
const logger = require('morgan'); | |
const argparse = require('argparse'); | |
const model = require('./model') | |
const indexRouter = require('./routes/index'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Normalize data set using min-max scaling | |
*/ | |
export function normalizeData(tensor){ | |
const data_max = tensor.max(); | |
const data_min = tensor.min(); | |
const normalized_tensor = tensor.sub(data_min).div(data_max.sub(data_min)); | |
return normalized_tensor; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as tf from '@tensorflow/tfjs'; | |
import * as tfvis from '@tensorflow/tfjs-vis'; | |
import { ForestDataset, FEATURE_NAMES } from './data'; | |
import { normalizeData } from './utils' | |
import * as ui from './ui'; | |
const forestdata = new ForestDataset(); | |
const tensors = {} | |
const LEARNING_RATE = 0.01 |