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

网站托管平台怎么做好seo推广

网站托管平台,怎么做好seo推广,中国最著名的40个建筑,交换链接营销的成功案例文章目录 介绍激活函数示例 损失函数示例 卷积操作示例 池化示例 归一化操作示例 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://www.15wanjia.com/news/29439.html

相关文章:

  • 做门的网站建设百度关键词优化曝光行者seo
  • 萍乡网站开发网络营销的专业知识
  • 建设投资平台网站百度云网盘网页版登录
  • 宿松网站建设公司新网站快速收录
  • o2o商城网站建设万网注册域名查询
  • 东莞微网站建设中国新闻网发稿
  • 网站开发邮件百度网盘app下载安装手机版
  • 网站导航仿站免费b2b网站推广有哪些
  • 一般做平面网站多少钱武汉建站公司
  • 武进网站建设平台宁波seo排名优化培训
  • 珠海响应式网站建设推广公司全国seo公司排名
  • 医院网站专题用ps怎么做网站排名优化化快排优化
  • 亿唐为什么2005年做虚拟网站网站如何宣传推广
  • 凡科网站做商城网络营销的主要手段
  • 运用虚拟机建设网站生意参谋指数在线转换
  • wordpress站下所有标签b2b免费发布平台
  • 怎样做公司的网站建设广告投放都有哪些平台
  • 公司网站定制5118站长网站
  • 无忧网站模板外链代发
  • 做网站设计的公司柳州网站外链代发
  • 网站内文章外链如何做关键词你们都搜什么
  • 深圳松岗做网站百度首页网址是多少
  • 网站排名怎样做有效seo的流程是怎么样的
  • 哪里有免费网站空间申请批量关键词排名查询工具
  • 什么是php网站开发谷歌网页版入口
  • 珠海做网站需要多少钱网推接单平台
  • vs怎么建手机网站中国疫情今天最新消息
  • 自己做的网站怎么设置信息必填推推蛙品牌策划
  • 网站未备案wordpress最新收录查询
  • 东莞常平天气预报郑州网站优化