我正在尝试在 Angular 上设计软件,使用带有 Angular 的 Tensorflow.js 正确猜测正确的书面文字
应用程序组件.ts
import { Component, ViewChild, OnInit } from '@angular/core';
import * as tf from '@tensorflow/tfjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
linearModel?: tf.Sequential;
prediction: any;
ngOnInit(){
// this.trainNewModel();
}
// async trainNewModel(){
// this.linearModel = tf.sequential();
// this.linearModel.add(tf.layers.dense({
// units: 1,
// inputShape:[1]
// }));
// this.linearModel.compile({
// loss: 'meanSquareError',
// optimizer: 'sgd'
// });
// const xs = tf.tensor1d([3.2,4.4,5.5,6.71,6.98,7.168,9.779,7.59,2.16]);
// const ys = tf.tensor1d([1.6,2.7,2.9,3.19,1.684,2.53,3.366,2.596,2.53,1.22]); …Run Code Online (Sandbox Code Playgroud)