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

成都网站建设类岗位图片 网站源码 采集

成都网站建设类岗位,图片 网站源码 采集,电商网站那些功能用到静态化功能,软件商店安装下载oppo课程来源#xff1a;人工智能实践:Tensorflow笔记2 文章目录前言断点续训主要步骤参数提取主要步骤总结前言 本讲目标:断点续训#xff0c;存取最优模型#xff1b;保存可训练参数至文本 断点续训主要步骤 读取模型#xff1a; 先定义出存放模型的路径和文件名#xff0…课程来源人工智能实践:Tensorflow笔记2 文章目录前言断点续训主要步骤参数提取主要步骤总结前言 本讲目标:断点续训存取最优模型保存可训练参数至文本 断点续训主要步骤 读取模型 先定义出存放模型的路径和文件名命名为.ckpt文件。 生成ckpt文件的时候会同步生成索引表所以通过判断是否存在索引表来知晓是不是已经保存过模型参数。 如果有了索引表就利用load_weights函数读取已经保存的模型参数。 code: checkpoint_save_path ./checkpoint/fashion.ckpt if os.path.exists(checkpoint_save_path .index):print(-------------load the model-----------------)model.load_weights(checkpoint_save_path)保存模型 保存模型参数可以使用TensorFlow给出的回调函数直接保存训练出来的模型参数 tf.keras.callbacks.ModelCheckpoint( filepath路径文件名(文件存储路径), save_weights_onlyTrue/False,(是否只保留参数模型) save_best_onlyTrue/False(是否只保留最优结果)) 执行训练过程中时加入callbacks选项: historymodel.fit(callbacks[cp_callback]) code: cp_callback tf.keras.callbacks.ModelCheckpoint(filepathcheckpoint_save_path,save_weights_onlyTrue,save_best_onlyTrue)history model.fit(x_train, y_train, batch_size32, epochs5, validation_data(x_test, y_test), validation_freq1,callbacks[cp_callback])第一次运行 第二次运行可以发现模型并不是从初始训练而是在基于保存的模型开始训练的这一点可以从准确率和损失看出 全部代码 import tensorflow as tf import osfashion tf.keras.datasets.fashion_mnist (x_train, y_train), (x_test, y_test) fashion.load_data() x_train, x_test x_train / 255.0, x_test / 255.0model tf.keras.models.Sequential([tf.keras.layers.Flatten(),tf.keras.layers.Dense(128, activationrelu),tf.keras.layers.Dense(10, activationsoftmax) ])model.compile(optimizeradam,losstf.keras.losses.SparseCategoricalCrossentropy(from_logitsFalse),metrics[sparse_categorical_accuracy])checkpoint_save_path ./checkpoint/fashion.ckpt if os.path.exists(checkpoint_save_path .index):print(-------------load the model-----------------)model.load_weights(checkpoint_save_path)cp_callback tf.keras.callbacks.ModelCheckpoint(filepathcheckpoint_save_path,save_weights_onlyTrue,save_best_onlyTrue)history model.fit(x_train, y_train, batch_size32, epochs5, validation_data(x_test, y_test), validation_freq1,callbacks[cp_callback]) model.summary() 参数提取主要步骤 设置打印的格式使所有参数都打印出来 np.set_printoptions(thresholdnp.inf) print(model.trainable_variables) 将所有可训练参数存入文本 file open(./weights.txt, w) for v in model.trainable_variables:file.write(str(v.name) \n)file.write(str(v.shape) \n)file.write(str(v.numpy()) \n) file.close() 完整代码: import tensorflow as tf import os import numpy as npnp.set_printoptions(thresholdnp.inf)fashion tf.keras.datasets.fashion_mnist (x_train, y_train), (x_test, y_test) fashion.load_data() x_train, x_test x_train / 255.0, x_test / 255.0model tf.keras.models.Sequential([tf.keras.layers.Flatten(),tf.keras.layers.Dense(128, activationrelu),tf.keras.layers.Dense(10, activationsoftmax) ])model.compile(optimizeradam,losstf.keras.losses.SparseCategoricalCrossentropy(from_logitsFalse),metrics[sparse_categorical_accuracy])checkpoint_save_path ./checkpoint/fashion.ckpt if os.path.exists(checkpoint_save_path .index):print(-------------load the model-----------------)model.load_weights(checkpoint_save_path)cp_callback tf.keras.callbacks.ModelCheckpoint(filepathcheckpoint_save_path,save_weights_onlyTrue,save_best_onlyTrue)history model.fit(x_train, y_train, batch_size32, epochs5, validation_data(x_test, y_test), validation_freq1,callbacks[cp_callback]) model.summary()print(model.trainable_variables) file open(./weights.txt, w) for v in model.trainable_variables:file.write(str(v.name) \n)file.write(str(v.shape) \n)file.write(str(v.numpy()) \n) file.close() 效果 总结 课程链接:MOOC人工智能实践TensorFlow笔记2
http://www.yutouwan.com/news/161236/

相关文章:

  • 北京网站快速优化排名wordpress微信商户支付
  • 网站建设分金手指专业w3c网站怎么做
  • 快速建设网站视频教程户外运动网站模板
  • 美食电子商务网站建设规划书网络营销推广的工具
  • 免费制作详情页的网站长沙网站设计公司重庆标志
  • 怎么建设一个营销型网站国家商标注册官网入口
  • jsp网站开发详解 下载网站建设 任务
  • 网站开发者取色工具wordpress没显示已发布
  • 工业和信息网站备案管理系统怎么查看网站开发语言的类型
  • 设计一个网站先做哪些构造网页qq登录记录网站
  • 百度上怎么做网站品牌传播策略
  • 个人网页设计模板网站电影网站开发开题报告
  • 查询网站备案时间查询php网站开发实用技术课后习题
  • 制作手机软件网站上海网站制作网络推广
  • 重庆做的好的房产网站深圳网站建设服
  • 全国建设网站图片创建全国文明城市黑板报
  • 做网站的属于什么行业c网站开发教程
  • 银川制作网站广州新闻发布
  • 免费拒绝收费网站平台式建站
  • 最好的网站推广软件做网站,就上凡科建站
  • 网站推广方案注意事项?自助建站的优势
  • 如何添加网站网站建设冷色调
  • 宁波seo网站服务企业专属空间登录
  • 网站制作经典案例百度做网站推广的费用
  • 成都网站建设公司创新互联做画册可以参考哪些网站
  • 企业网站建设 论文wordpress 米课
  • 国际网站建站免费的源码
  • 腾讯免费企业邮箱注册申请最新黑帽seo培训
  • 泉州企业自助建站系统麒麟seo外推软件
  • 南通通州区网站制作抖音做我女朋友网站