项目作者: AndrewJBateman
项目描述 :
Tensorflow in angular8.
高级语言: TypeScript
项目地址: git://github.com/AndrewJBateman/angular-tensorflow-notes.git
Angular TensorFlow Notepad
- Code to experiment with machine learning using Tensorflow.js, starting with recognising numbers. Tutorial code from Fireship (see ref in ‘Inspiration’) cloned then updated to Angular 13. All dependencies updated. Requires some fixes to work, due to updates. The plan is to use this to try new Tensorflow ideas.
- Note: to open web links in a new window use: ctrl+click on link




Table of contents
General info
- “TensorFlow.js is an open-source hardware-accelerated JavaScript library for training and deploying machine learning models.“
Screenshots

Technologies
Setup
Code Examples
async trainNewModel() {
// Define a model for linear regression.
this.linearModel = tf.sequential();
this.linearModel.add(tf.layers.dense({units: 1, inputShape: [1]}));
// Prepare the model for training: Specify the loss and the optimizer.
this.linearModel.compile({loss: 'meanSquaredError', optimizer: 'sgd'});
// Training data, completely random stuff
const xs = tf.tensor1d([3.2, 4.4, 5.5, 6.71, 6.98, 7.168, 9.779, 6.182, 7.59, 2.16, 7.042, 10.71, 5.313, 7.97, 5.654, 9.7, 3.11]);
const ys = tf.tensor1d([1.6, 2.7, 2.9, 3.19, 1.684, 2.53, 3.366, 2.596, 2.53, 1.22, 2.87, 3.45, 1.65, 2.904, 2.42, 2.4, 1.31]);
// Train
await this.linearModel.fit(xs, ys)
console.log('model trained')
}
Features
Status & To-Do List
- Status: not compiling due to errors from tensorflow update to v3
- To-Do: Correct: Namespace has no exported member, loadModel does not exist.., fromPixels does not exist.
Inspiration
License
- This project is licensed under the terms of the MIT license.