当前位置:网站首页>Pytorch框架学习记录9——非线性激活
Pytorch框架学习记录9——非线性激活
2022-08-01 20:36:00 【柚子Roo】
Pytorch框架学习记录9——非线性激活
1. ReLU函数介绍
torch.nn.ReLU
(inplace=False)
参数
inplace- 可以选择就地执行操作。默认:
False
形状:
输入:( * ), 在哪里**表示任意数量的维度。输出:( * ),与输入的形状相同。
import torch
from torch import nn
input = torch.tensor([[1, 0.5],
[4, -2]])
input = torch.reshape(input, (-1, 1, 2, 2))
class Test(nn.Module):
def __init__(self):
super(Test, self).__init__()
self.relu = nn.ReLU(inplace=False)
def forward(self, input):
input = self.relu(input)
return input
test = Test()
output = test(input)
print(output)
2. Sigmoid函数
形状:
- 输入:( * ), 在哪里**表示任意数量的维度。
- 输出:( * ),与输入的形状相同。
import torchvision
from torch import nn
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter
dataset = torchvision.datasets.CIFAR10(root='./dataset', train=False, transform=torchvision.transforms.ToTensor(), download=True)
dataloader = DataLoader(dataset, batch_size=64)
class Test(nn.Module):
def __init__(self):
super(Test, self).__init__()
self.sigmod = nn.Sigmoid()
def forward(self, input):
input = self.sigmod(input)
return input
test = Test()
writer = SummaryWriter('logs')
step = 0
for data in dataloader:
imgs, target = data
output = test(imgs)
writer.add_images("sigmod", output, global_step=step)
step += 1
writer.close()
边栏推荐
- 进行交互或动画时如何选择Visibility, Display, and Opacity
- Different operating with different locks, rounding
- 微信小程序云开发|个人博客小程序
- 不同的操作加不同的锁详解
- idea插件generateAllSetMethod一键生成set/get方法以及bean对象转换
- Interpretation of the meaning of each dimension of two-dimensional, three-dimensional, and four-dimensional matrices
- 给定中序遍历和另外一种遍历方法确定一棵二叉树
- 【Dart】dart之mixin探究
- 【Untitled】
- Acrel-5010重点用能单位能耗在线监测系统在湖南三立集团的应用
猜你喜欢
WhatsApp群发实战分享——WhatsApp Business API账号
Application of Acrel-5010 online monitoring system for key energy consumption unit energy consumption in Hunan Sanli Group
StringTable详解 串池 性能调优 字符串拼接
外骨骼机器人(七):标准步态数据库
【Dart】dart构造函数学习记录(含dart单例模式写法)
OSG Notes: Set DO_NOT_COMPUTE_NEAR_FAR to manually calculate far and near planes
面试突击70:什么是粘包和半包?怎么解决?
【无标题】
Godaddy domain name resolution is slow and how to use DNSPod resolution to solve it
进行交互或动画时如何选择Visibility, Display, and Opacity
随机推荐
任务调度线程池基本介绍
KDD2022 | 自监督超图Transformer推荐系统
Digital twin Beijing the imperial palace, yuan universe is the process of tourism
[Energy Conservation Institute] Comparative analysis of smart small busbar and column head cabinet solutions in data room
我的驾照考试笔记(4)
小数据如何学习?吉大最新《小数据学习》综述,26页pdf涵盖269页文献阐述小数据学习理论、方法与应用
Remove 360's detection and modification of the default browser
【torch】张量乘法:matmul,einsum
专利检索常用的网站有哪些?
Use WeChat official account to send information to designated WeChat users
StringTable Detailed String Pool Performance Tuning String Concatenation
Multithreaded producers and consumers
漏刻有时文档系统之XE培训系统二次开发配置手册
【多任务优化】DWA、DTP、Gradnorm(CVPR 2019、ECCV 2018、 ICML 2018)
大整数相加,相减,相乘,大整数与普通整数的相乘,相除
系统收集集
仿牛客论坛项目
我的驾照考试笔记(2)
Failed to re-init queues : Illegal queue capacity setting (abs-capacity=0.6) > (abs-maximum-capacity
泰德制药董事长郑翔玲荣膺“2022卓越影响力企业家奖” 泰德制药荣获“企业社会责任典范奖”