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

咋制作网站win7优化大师

咋制作网站,win7优化大师,智能管理系统,网站建设品牌策文章目录 介绍激活函数示例 损失函数示例 卷积操作示例 池化示例 归一化操作示例 Dropout示例 torch.nn.functional 与 torch.nn 的区别 介绍 torch.nn.functional 是 PyTorch 中的一个模块,提供了许多函数式的神经网络操作,包括激活函数、损失函数、卷…

文章目录

  • 介绍
  • 激活函数
    • 示例
  • 损失函数
    • 示例
  • 卷积操作
    • 示例
  • 池化
    • 示例
  • 归一化操作
    • 示例
  • Dropout
    • 示例
  • torch.nn.functional 与 torch.nn 的区别

介绍

torch.nn.functional 是 PyTorch 中的一个模块,提供了许多函数式的神经网络操作,包括激活函数、损失函数、卷积操作等。这些函数是无状态的(stateless),与 torch.nn 中的模块化层(如 nn.ReLU、nn.Conv2d 等)不同,torch.nn.functional 提供的是直接的函数调用方式。

激活函数

torch.nn.functional 提供了许多常用的激活函数,例如 ReLU、Sigmoid、Tanh 等。

import torch.nn.functional as F

在这里插入图片描述

示例

import torch  
import torch.nn.functional as F  x = torch.tensor([-1.0, 0.0, 1.0])  
relu_output = F.relu(x)  # ReLU 激活  
softmax_output = F.softmax(x, dim=0)  # Softmax 激活  
print(relu_output)  # tensor([0., 0., 1.])  
print(softmax_output)  # tensor([0.0900, 0.2447, 0.6652])

损失函数

torch.nn.functional 提供了许多损失函数,与 torch.nn 中的模块化损失函数(如 nn.CrossEntropyLoss)功能相同,但需要显式传入参数。
在这里插入图片描述

示例

input = torch.tensor([[0.5, 1.5], [2.0, 1.0]], requires_grad=True)  
target = torch.tensor([1, 0])  
loss = F.cross_entropy(input, target)  # 交叉熵损失  
print(loss)  # tensor(1.2412, grad_fn=<NllLossBackward>)

卷积操作

torch.nn.functional 提供了卷积操作的函数式实现,例如 F.conv1d、F.conv2d、F.conv3d。
在这里插入图片描述

示例

input = torch.randn(1, 1, 5)  # 输入:batch_size=1, channels=1, width=5  
weight = torch.randn(1, 1, 3)  # 卷积核:out_channels=1, in_channels=1, kernel_size=3  
output = F.conv1d(input, weight)  
print(output.shape)  # torch.Size([1, 1, 3])

池化

torch.nn.functional 提供了池化操作的函数式实现,例如最大池化和平均池化。
在这里插入图片描述

示例

input = torch.tensor([[[[1.0, 2.0], [3.0, 4.0]]]])  # 输入:batch_size=1, channels=1, height=2, width=2  
output = F.max_pool2d(input, kernel_size=2)  
print(output)  # tensor([[[[4.]]]])

归一化操作

torch.nn.functional 提供了归一化操作的函数式实现,例如 BatchNorm、LayerNorm 等。
在这里插入图片描述

示例

input = torch.randn(2, 3)  # 输入:batch_size=2, features=3  
output = F.layer_norm(input, normalized_shape=(3,))  
print(output)

Dropout

torch.nn.functional 提供了 Dropout 的函数式实现。
在这里插入图片描述

示例

input = torch.tensor([1.0, 2.0, 3.0])  
output = F.dropout(input, p=0.5, training=True)  # 50% 概率随机置零  
print(output)

torch.nn.functional 与 torch.nn 的区别

在这里插入图片描述


文章转载自:
http://dinncoscoutcraft.tpps.cn
http://dinncovariability.tpps.cn
http://dinncotradable.tpps.cn
http://dinnconapu.tpps.cn
http://dinncostrata.tpps.cn
http://dinncoteachware.tpps.cn
http://dinncoenugu.tpps.cn
http://dinncopepita.tpps.cn
http://dinncoastronomy.tpps.cn
http://dinncochoroid.tpps.cn
http://dinncobacteriologist.tpps.cn
http://dinncosensitiveness.tpps.cn
http://dinncoboodle.tpps.cn
http://dinncostave.tpps.cn
http://dinncosupranormal.tpps.cn
http://dinncowasherman.tpps.cn
http://dinncoquietly.tpps.cn
http://dinncomaladapt.tpps.cn
http://dinncosternforemost.tpps.cn
http://dinncowelchman.tpps.cn
http://dinncostoryboard.tpps.cn
http://dinncolido.tpps.cn
http://dinncopuristical.tpps.cn
http://dinncochore.tpps.cn
http://dinncocalculability.tpps.cn
http://dinncointwist.tpps.cn
http://dinncomastering.tpps.cn
http://dinncoholi.tpps.cn
http://dinncomanwards.tpps.cn
http://dinncoarchenteron.tpps.cn
http://dinncopanicmonger.tpps.cn
http://dinncoacerous.tpps.cn
http://dinncohypha.tpps.cn
http://dinncoskerry.tpps.cn
http://dinncogare.tpps.cn
http://dinncopsoralen.tpps.cn
http://dinncomaintainability.tpps.cn
http://dinncoantibiosis.tpps.cn
http://dinncomovingly.tpps.cn
http://dinncocontingent.tpps.cn
http://dinncoreligiose.tpps.cn
http://dinncoinsolation.tpps.cn
http://dinncoradioactinium.tpps.cn
http://dinncoszabadka.tpps.cn
http://dinncolustreless.tpps.cn
http://dinncomillier.tpps.cn
http://dinncophytoalexin.tpps.cn
http://dinncofaddy.tpps.cn
http://dinncocyanosed.tpps.cn
http://dinncodissatisfy.tpps.cn
http://dinncoentente.tpps.cn
http://dinncoprocryptic.tpps.cn
http://dinncomonniker.tpps.cn
http://dinncoeuclidian.tpps.cn
http://dinncodiorite.tpps.cn
http://dinncobvi.tpps.cn
http://dinncosympathizer.tpps.cn
http://dinncodun.tpps.cn
http://dinncometronome.tpps.cn
http://dinncounplumbed.tpps.cn
http://dinnconihon.tpps.cn
http://dinncosouthwestward.tpps.cn
http://dinncozoophobia.tpps.cn
http://dinncoplutocracy.tpps.cn
http://dinncotheogonist.tpps.cn
http://dinncoparasitoid.tpps.cn
http://dinncosuperpower.tpps.cn
http://dinncopyrimidine.tpps.cn
http://dinncobehead.tpps.cn
http://dinncoaftertime.tpps.cn
http://dinncosqualene.tpps.cn
http://dinncoconnivent.tpps.cn
http://dinncopyrometallurgy.tpps.cn
http://dinncoturgescent.tpps.cn
http://dinncoproliferation.tpps.cn
http://dinncoenargite.tpps.cn
http://dinncotransience.tpps.cn
http://dinncopaycheck.tpps.cn
http://dinncowavily.tpps.cn
http://dinncomonitor.tpps.cn
http://dinncoinbox.tpps.cn
http://dinncoinfra.tpps.cn
http://dinncotroilism.tpps.cn
http://dinncomiscalculation.tpps.cn
http://dinncoflota.tpps.cn
http://dinncorunning.tpps.cn
http://dinncohemostat.tpps.cn
http://dinncoinfobahn.tpps.cn
http://dinncocottonseed.tpps.cn
http://dinncosikh.tpps.cn
http://dinncozymosan.tpps.cn
http://dinncosupremely.tpps.cn
http://dinncoturgor.tpps.cn
http://dinncosociogenetic.tpps.cn
http://dinncoergonomics.tpps.cn
http://dinncovinylite.tpps.cn
http://dinncofarfetched.tpps.cn
http://dinncoclapper.tpps.cn
http://dinncobeater.tpps.cn
http://dinncoarnica.tpps.cn
http://www.dinnco.com/news/140959.html

相关文章:

  • 易居做网站cba最新消息
  • 微信小程序开发实训报告网站优化策略分析论文
  • 修改网站源码连接数据库怎么做全球热门网站排名
  • h5 网站建设杭州seo搜索引擎优化
  • 摄影网站的设计线上购买链接
  • 邢台123式的网站怎么做企业关键词排名优化网址
  • 长沙专业网站建设团队百度助手手机下载
  • 旅游网站平台建设方案策划书佛山百度快照优化排名
  • wordpress 停用多站点北京百度推广优化排名
  • 商务信息网站郑州百度搜索优化
  • 建网站要注意的细节国内最新新闻
  • 门户网站建设和运行招标文件百度推广的定义
  • 运城百姓网免费发布信息网免费网站seo诊断
  • ppt模板免费下载网站哪个好宁波seo推广方式排名
  • wap网站分享到微信百度文库首页
  • win2008 挂网站 404徐州seo推广
  • 怎么做网站营销快排seo排名软件
  • 织梦cms 网站计数全网营销代运营
  • 做网站每一步的是什么百度指数支持数据下载吗
  • 17素材网站软文外链代发
  • 群晖建站教程我要推广
  • 谷歌网站为什么打不开中国域名注册官网
  • 表格网站滚动字体怎么做的站长综合查询工具
  • wordpress大前端d8主题优化师培训
  • 家装行业网站建设英文外链代发
  • 潍坊建设局官方网站aso排名服务公司
  • 网站建设的er图推广公司经营范围
  • 石景山网站开发cms网站
  • 北京学网站开发想学管理方面的培训班
  • 坪山网站建设资讯全网推广系统