Pytorch – reshape和view的用法和区别
1 torch.reshape 形式 torch.reshape(input, shape) 功能 返回一个与输入张量数据和元素数相同的,但是形状为shape的张量。 参数 input:需要被重新定义形状的输入张量 shape:新的形状 使用示例 import torch if __name__ =…
- Pytorch
- 2022-12-09
Pytorch – torch.cat函数
1 torch.cat函数 形式 torch.cat(tensors, dim=0, *, out=None) 功能 在指定的维度连接给定序列的张量,所有张量必须具有相同的形状(连接维度除外)或者为空。 参数 tensors:相同形状的张量序列,非空张量必须具有相同形状(连接维度除外) dim:张量…
- Pytorch
- 2022-12-08
Pytorch – torch.unsqueeze和torch.squeeze函数
Pytorch中,unsqueeze和squeeze为两个对应的反操作函数,其中,unsqueeze主要用于为输入张量升维,squeeze主要用于给张量降维,两者的具体用法可以参考下文。 1 unsqueeze 形式 torch.unsqueeze(input, dim) 或者 Tensor.uns…
- Pytorch
- 2022-12-08
Pytorch – 创建随机Tensor的常用方法
本文对Pytorch中创建随机数Tensor的一些常用方法进行总结,主要包括 randn randn_like rand rand_like randint randint_like 1 torch.randn 形式 torch.randn(*size, *, out=None, dtype=Non…
- Pytorch
- 2022-12-08
Pytorch – torch.nn.Conv2d参数详解与使用
1 torch.nn.Conv2d torch.nn.Conv2d主要对输入Tensor应用2D卷积。 比如输入(N,C_{in},H,W)维度的Tensor,则输出(N,C_{out},H,W)的Tensor,这两者的关系可以描述为 \operatorname{out}\left(N_{i}, C…
- Pytorch
- 2022-12-07
TensorRT – onnx_graphsurgeon工具库的安装与API简介
1 onnx_grapgsurgeon 1.1 onnx_grapgsurgeon简介 onnx_grapgsurgeon是NVIDIA提供的创建和修改onnx模型的便捷易用工具库。 Github:https://github.com/NVIDIA/TensorRT/tree/master/tool…
- TensorRT
- 2022-12-05
TensorRT – 转换onnx模型出现Slice_74 requires bool or uint8 I/O but node can not be handled by Myelin错误
1 Error Code 2: Internal Error (Slice_74 requires bool or uint8 I/O but node can not be handled by Myelin错误 1.1 问题 今天在用TensorRT转化onnx模型出现了以下错误 转换onnx模…
- TensorRT
- 2022-12-02
Python – onnx导出模型出现RuntimeError: Exporting the operator pad_sequence to ONNX opset version 13 is not supported错误
1 onnx导出模型出现RuntimeError: Exporting the operator pad_sequence to ONNX opset version 13 is not supported错误 今天在pytorch中导出模型为onnx时,由于使用了from torch.nn.uti…
- 模型部署
- 2022-12-01
TensortRT – 转换模型出现Could not locate zlibwapi.dll. Please make sure it is in your library path!错误
1 TensortRT转换模型出现Could not locate zlibwapi.dll. Please make sure it is in your library path!错误 1.1 问题 今天在使用TensorRT转换onnx模型时出现了以下错误 [12/01/2022-09:03:…
- TensorRT
- 2022-12-01
Python – 使用onnxruntime加载和推理onnx模型
1 onnxruntime Onnx runtime是一个跨平台的机器学习模型加速器,可以在不同的硬件和操作系统上运行,可以加载和推理任意机器学习框架导出的onnx模型并进行加速。 如要使用onnxruntime,一般通过以下步骤: 从机器学习框架中将模型导出为onnx 使用onnxruntime加…
- 模型部署
- 2022-11-30
Pytorch – 训练网络时出现_pickle.UnpicklingError: pickle data was truncated错误
1 Pytorch训练网络时出现_pickle.UnpicklingError: pickle data was truncated错误 今天重新在一个大的数据集上重新训练一个模型时,在第二个epoch时出现了_pickle.UnpicklingError: pickle data was trun…
- Pytorch
- 2022-11-07
模型训练 – 解决启动深度学习项目出现OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized问题
今天在开始跑一个深度学习项目时,在启动时,程序出现了以下的错误, OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized. OMP: Hint This means that …
- 模型训练
- 2022-09-30