分类 Study 下的文章

9、PyTorch的nn.Sequential及ModuleList源码


train# 实例化一个模型,在模型后调用.train(True),说明我们将该模型设置为训练模式 def train(self: T, mode: bool = True) -> T: r"""Sets the module in training mode. This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`, etc...

24、手写并验证向量内积实现PyTorch二维卷积


该9步过程可以看作是一个矩阵跟另外一个矩阵的矩阵相乘将每步input拉直,例如左上角第一个深蓝色区域拉为332001312行向量,再将Kernel拉为$(012220012)^T$列向量相乘得到第一个最终结果的左上角第一个数值12.0So,上边九步运算可以视为行数为9的矩阵和列数为9的矩阵进行矩阵乘法,再将相乘的结果reshape为欲得到的结果Other Method实现一个长度为25的内积目前Kernel只是3×3的范围大小,若是将Kernel填充一下,eg.左上角第一幅图,Kernel只有9个数,但是我们可以脑补一下浅蓝色部分都填充为0,每一步都将Kernel填充浅蓝色部分为0,那么,原问题就变为25行向量和25列向量相乘。Coding希望把region_vector都放入到region_matrix中,再将region_matrix与Kernel_mat...

23、手写并验证滑动相乘实现PyTorch二维卷积


蓝色的input_feature 5*5深蓝色小字部分kernel_size 3*3绿色部分out_feature 3*3stride = 1padding = 0channel = 1padding = 1stride = 2底部input_channels = 2顶端绿色为out_channels = 3kernels = 2*3 = 6(倒数第二行)input = input_feature_map # 卷积输入特征图 kernel = conv_layer.weight.data # 卷积核 input = torch.randn(5, 5) # 卷积输入特征图 kernel = torch.randn(3, 3) # 卷积核 bias = torch.randn(1) # 卷积偏置项,默认输出通道数目=1 # Func1 用原始的矩阵运算...

22、Pytorch nn.Conv2d


22、Pytorch nn.Conv2dCLASS torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None)[ ](https://pytorch.org/docs/stable/_modules/torch/nn/modules/conv.html#Conv2d)torch import torch.nn as nn import torch.nn.functional as F conv_layer = nn.Conv2d(in_channels=1, out_channels=1, kernel_s...

自建中继使用RustDesk


服务端搭建中继服务器推荐使用linux来搭建中继服务器,且有公网ip使用宝塔面板# Xshell连接服务器…… cd /root mkdir rustdesk cd rustdesk wgethttps://github.com/rustdesk/rustdesk-server/releases/download/1.1.6/rustdesk-server-linux-x64.zip unzip rustdesk-server-linux-x64.zip ls 查看有无hbbr和hbbs两份文件hbbr:通常用于建立连接。它可能是一种服务端应用程序,负责接受客户端的连接请求,验证客户端身份,并建立起双向通信的连接。在某些情况下,hbbr 可能充当中继服务器或者数据交换的中心节点。hbbs:通常用于传输数据。它可能是一种客户端应用程序,负责向 hbbr 或其他服...

召唤看板娘