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

网站建设论文要求什么叫专业建设

网站建设论文要求,什么叫专业建设,天长两学一做网站,网站开发是前端还是后台Autocasting和GradScaler是什么 torch.autocast 是一个上下文管理器#xff0c;它可以将数据类型从 float32 自动转换为 float16。这可以提高性能#xff0c;因为 float16 比 float32 更小#xff0c;因此可以更快地处理。torch.cuda.amp.GradScaler 是一个类#xff0c;它…Autocasting和GradScaler是什么 torch.autocast 是一个上下文管理器它可以将数据类型从 float32 自动转换为 float16。这可以提高性能因为 float16 比 float32 更小因此可以更快地处理。torch.cuda.amp.GradScaler 是一个类它可以自动缩放梯度以便在使用混合精度时保持准确性。这很重要因为使用混合精度时梯度可能会被缩小从而导致准确性下降。 bfloat16是什么 BFloat16 (Brain Floating Point)是一种16bit的浮点数格式动态表达范围和float32是一样的但是精度低。 动态表达范围是指浮点数可以表示的数值范围。 BFloat16 的精度降低是因为它使用 16 位来存储数据而 float32 使用 32 位来存储数据。 BFloat16 的名称来自它的开发者Google Brain。 Autocasting Autocast 实例可以作为上下文管理器或装饰器允许您的脚本的部分在混合精度下运行。 autocast 应该只包装您的网络的前向传递包括损失计算。不推荐在自动转换下进行反向传递。反向操作在与相应的正向操作相同的类型下运行。 # Creates model and optimizer in default precision model Net().cuda() optimizer optim.SGD(model.parameters(), ...)for input, target in data:optimizer.zero_grad()# Enables autocasting for the forward pass (model loss)with autocast():output model(input)loss loss_fn(output, target)# Exits the context manager before backward()loss.backward()optimizer.step()在自动转换启用区域中生成的浮点张量可能为 float16 # Creates some tensors in default dtype (here assumed to be float32) a_float32 torch.rand((8, 8), devicecuda) b_float32 torch.rand((8, 8), devicecuda) c_float32 torch.rand((8, 8), devicecuda) d_float32 torch.rand((8, 8), devicecuda)with autocast():# torch.mm is on autocasts list of ops that should run in float16.# Inputs are float32, but the op runs in float16 and produces float16 output.# No manual casts are required.e_float16 torch.mm(a_float32, b_float32)# Also handles mixed input typesf_float16 torch.mm(d_float32, e_float16)# After exiting autocast, calls f_float16.float() to use with d_float32 g_float32 torch.mm(d_float32, f_float16.float())autocast(enabledFalse) # Creates some tensors in default dtype (here assumed to be float32) a_float32 torch.rand((8, 8), devicecuda) b_float32 torch.rand((8, 8), devicecuda) c_float32 torch.rand((8, 8), devicecuda) d_float32 torch.rand((8, 8), devicecuda)with autocast():e_float16 torch.mm(a_float32, b_float32)with autocast(enabledFalse):# Calls e_float16.float() to ensure float32 execution# (necessary because e_float16 was created in an autocasted region)f_float32 torch.mm(c_float32, e_float16.float())# No manual casts are required when re-entering the autocast-enabled region.# torch.mm again runs in float16 and produces float16 output, regardless of input types.g_float16 torch.mm(d_float32, f_float32)GradScaler 如果特定操作的前向传递具有 float16 输入则该操作的反向传递将生成 float16 梯度。 小幅度梯度值可能无法表示为 float16。这些值将刷新为零“下溢”因此相应参数的更新将丢失。 为了防止下溢梯度缩放会将网络的损失乘以一个缩放因子并在缩放的损失上调用反向传递。然后通过网络流回的梯度将按相同的因子进行缩放。换句话说梯度值具有更大的幅度因此不会刷新为零。 在优化器更新参数之前应先unscaled每个参数的梯度以便缩放因子不会干扰学习率。 import torch from torch import nn, optim# Creates model and optimizer in default precision model Net().cuda() optimizer optim.SGD(model.parameters(), ...)# Creates a gradient scale object scale torch.cuda.amp.GradScaler()for input, target in data:optimizer.zero_grad()# Enables autocasting for the forward pass (model loss)with autocast():output model(input)loss loss_fn(output, target)# Scales the loss before backward()scale.scale(loss).backward()# Unscales the gradients after backward()scale.step(optimizer)scale.update()
http://www.dnsts.com.cn/news/61652.html

相关文章:

  • 网站制作com cn域名有什么区别wordpress注释符号
  • 对中国建设银行网站的缺点企业年报系统登录
  • 北外网院网站建设作业安全生产规章制度建筑公司网站
  • 广告软文范例大全100郑州互联网seo使用教程
  • drupal网站开发wordpress怎么转换为静态链接
  • 网站建设服务合同缴纳印花税吗桂林旅游网站建设
  • 洛阳网站建设培训一站式服务建站
  • 哪能建设网站宝安附近公司做网站建设哪家效益快
  • 石材网站建设建网站公司深
  • 做301重定向会影响网站权重吗组建团队建设网站与开发需要多少钱
  • 商城网站后台模板杭州知名建设网站设计
  • 网站建设图片代码做电影网站赚钱的方法
  • win8 metro风格网站后台管理模板网站代运营要多少费用吗
  • 没有网站怎么做cps百度网站域名注册
  • 太原网站建设加王道下拉建网站电话
  • 网站写手怎么做天津西青区离哪个火车站近
  • 做网站优化推广多少钱公司注册核名查询官网
  • 网站改版需求分析php做网站麻烦吗
  • vi设计用什么软件成都seo培训
  • 南宁公司做网站腾云网建站
  • 招远网站建设价格网站推广外链怎么做
  • 内蒙古建设监理协会网站建网站前期设计用那软件
  • 淮南招聘网站建设百度电话
  • 道滘东莞微信网站建设江苏住房与城乡建设厅网站
  • 信息技术八年级上册网站建设游戏官网平台
  • 门户网站创新的方式有南京seo圈子
  • 网站建设题库含答案12306网站是是阿里巴巴做的吗
  • app网站做二手交易龙岩app定制开发
  • 平罗县住房和城乡建设局网站个人网页设计欣赏欣赏
  • 网站信息内容建设管理网站建设在学校中的作用