当前位置: 首页 > news >正文

药企网站怎么做公司经营范围网站开发及运营

药企网站怎么做,公司经营范围网站开发及运营,关于产品网站建设的问题,网上开店加盟目的 利用tensorflow.js训练模型#xff0c;搭建神经网络模型#xff0c;完成手写数字识别 设计 简单三层神经网络 输入层 28*28个神经原#xff0c;代表每一张手写数字图片的灰度隐藏层 100个神经原输出层 -10个神经原#xff0c;分别代表10个数字 代码 // 导入 Ten…目的 利用tensorflow.js训练模型搭建神经网络模型完成手写数字识别 设计 简单三层神经网络 输入层 28*28个神经原代表每一张手写数字图片的灰度隐藏层 100个神经原输出层 -10个神经原分别代表10个数字 代码 // 导入 TensorFlow.js 库 import tf from tensorflow/tfjs; import * as tfjsnode from tensorflow/tfjs-node; import * as tfvis from tensorflow/tfjs-vis; import fs from fs; import plot from nodeplotlib; // 定义模型 const model tf.sequential();// 添加输入层 model.add(tf.layers.dense({ units: 64, inputShape: [784], activation: relu }) );// 添加隐藏层 model.add(tf.layers.dense({ units: 100, activation: relu }));// 添加输出层 model.add(tf.layers.dense({ units: 10, activation: softmax }));// 编译模型 model.compile({optimizer: sgd,loss: categoricalCrossentropy,metrics: [accuracy], }); const trainDataLen 3000; const testDataLen 2000;// 加载 MNIST 数据集 import pkg from mnist; const { set: Dataset } pkg; const set Dataset(trainDataLen, testDataLen); const trainingSet set.training; const testSet set.test;const trainXs []; const testXs [];const trainLabels []; const testLabels [];for (let i 0; i trainingSet.length; i) {trainXs.push(trainingSet[i].input);trainLabels.push(trainingSet[i].output.indexOf(1)); }for (let i 0; i testSet.length; i) {testXs.push(testSet[i].input);testLabels.push(testSet[i].output.indexOf(1)); }// 准备数据 const trainXsTensor tf.tensor(trainXs, [trainDataLen, 784]); const trainYsOneHot tf.oneHot(trainLabels, 10);//记录每轮模型训练中的损失和精度为了绘制曲线图 var accPlot []; var lossPlot [];// 模型训练 model.fit(trainXsTensor, trainYsOneHot, {batchSize: 64,epochs: 100,validationSplit: 0.2,callbacks: {onEpochBegin: (epoch) console.log(Epoch ${epoch 1} started...),onEpochEnd: async (epoch, logs) {console.log(Epoch ${epoch 1} completed. Loss: ${logs.loss.toFixed(3)}, Accuracy: ${logs.acc.toFixed(3)});//记录loss和acc绘制曲线图accPlot.push(logs.acc.toFixed(3));lossPlot.push(logs.loss.toFixed(3));await tf.nextFrame(); // 防止阻塞},onBatchEnd: async (batch, logs) {console.log(Batch ${batch} completed. Loss: ${logs.loss.toFixed(3)}, Accuracy: ${logs.acc.toFixed(3)});await tf.nextFrame(); // 防止阻塞},},}).then((history) {console.log(Training completed!, history);//绘制模型训练过程中的损失函数和模型精度曲线变化const epochs Array.from({ length: lossPlot.length }, (_, i) i 1);plot.plot([{ x: epochs, y: lossPlot, name: Loss },{ x: epochs, y: accPlot, name: Accuracy },],{filename: loss_acc.png,});//模型评估const testXsTensor tf.tensor(testXs, [testDataLen, 784]);const testYsOneHot tf.oneHot(testLabels, 10);const result model.evaluate(testXsTensor, testYsOneHot);const testLoss result[0].dataSync()[0];const testAccuracy result[1].dataSync()[0];console.log(Test loss: ${testLoss.toFixed(3)});console.log(Test accuracy: ${testAccuracy.toFixed(3)});//保存模型model.save(file://./my-model).then(() {console.log(Model saved!);});}); package.json {name: neural_network,version: 1.0.0,description: ,type: module,main: mlpTest.js,scripts: {test: echo \Error: no test specified\ exit 1,},author: ,license: ISC,dependencies: {tensorflow/tfjs: ^4.17.0,tensorflow/tfjs-node: ^4.17.0,tensorflow/tfjs-vis: ^1.0.0,mnist: ^1.1.0,nodeplotlib: ^0.7.7},devDependencies: {babel/core: ^7.0.0,babel/preset-env: ^7.0.0,babel-loader: ^8.0.0,webpack: ^5.0.0,webpack-cli: ^4.0.0} }模型结果 损失函数与模型精度变化
http://www.pierceye.com/news/945688/

相关文章:

  • 网站后台怎么添加图片大连精美网站制作
  • 电子商务网站建设规划说明书长沙百度快速排名
  • 自由建网站的网络程序在哪建设网站
  • 做u盘的老外网站黑龙江省住房和城乡建设厅官网
  • 网站logo如何替换wordpress怎么实现付费可见
  • 广州网站建设公司排行南宁企业网站建站
  • 网站优化总结报告个人博客网
  • 愿景 做中国最受欢迎的互联网网站找小程序
  • 重庆seowhy整站优化即时设计是什么软件
  • 哈尔滨网站建设哪个好做网站和域名
  • 制作网站的步骤和过程无锡网站改版多少钱
  • 网站建设与维护实训ppt可以在线做动图的网站
  • 软件开发外包网站开发系统的流程
  • 花卉网站建设策划方案二手房发布网站怎么做
  • 公司做影视网站侵权iis配置网站访问权限
  • 做网站的时候卖过假货而出过事如何做tiktok的数据排行网站
  • 给网站网站做推广获奖网站设计
  • 河南建设厅网站查证报名网站开发多钱
  • 杭州做网站 做小程序网站百度知道怎么做推广
  • 网站防红链接怎么做国内设计欣赏网站
  • 网站被黑咋样的wordpress导入用户数据库
  • wordpress 插件设计搜索引擎优化常用方法
  • ps怎样做网站大图wordpress固定链接精简
  • 学校网站推广方案商城系统app
  • 图书馆管理系统产品介绍网站如何做seo
  • 威县企业做网站做网站游戏的网站有哪些
  • 如何做网站二维码广州营销型网站建设
  • 网站网页转小程序教程网站建设公司 枫子伽叩
  • 做民宿哪家网站最好网站推广技巧有哪些?
  • 北京做网站推广兼职wordpress 分段循环