随笔分类 - PyTorch
摘要:【PyTorch】scatter 参数: dim (int) – the axis along which to index index (LongTensor) – the indices of elements to scatter, can be either empty or the sam
阅读全文
摘要:一直以来对于软件的版本对应关系有困惑,其实我们可以从这个官方链接上得到指点: https://download.pytorch.org/whl/torch_stable.html 比如我们要安装 PyTorch1.4.0,可以先从上面网站上找到对应关系,再使用以下命令进行下载: pip instal
阅读全文
摘要:torch.squeeze 分为两种情况: 不指定维度 或 指定维度 1. 不指定维度 Example 2. 指定维度 & `output: (A, 1, B)` & `output: (A, B)` Example Note: The returned tensor shares the stor
阅读全文
摘要:声明:本文大部分内容是从知乎、博客等知识分享站点摘录而来,以方便查阅学习。具体摘录地址已在文章底部引用部分给出。 1. 查看模型每层输出详情 2. 梯度裁减 3. 扩展图片维度 因为训练时数据维度一般为(batch_size, c, h,, w),而测试时如果只输入一张图片,则需要进行维度扩展。 方
阅读全文
摘要:PyTorch中的MaxPool(最大池化)有一个属性:ceil_mode,默认为False(地板模式),为True时是天花板模式。
阅读全文
摘要:1. OSError: [Error 12] Cannot allocate memory 解决办法: 出现这个错误时我是绝望的。。。因为我看了别人的解决办法,要加内存条才能解决。。。但是我不甘心,想了很久——发现了一个解决办法:将 DataLoader 中的 设置为1。缺点:数据加载必然变得很慢,
阅读全文
摘要:PyTorch : torch.nn.xxx 和 torch.nn.functional.xxx 在写 PyTorch 代码时,我们会发现在 和 中有一些功能重复的操作,比如卷积、激活、池化。这些操作有什么不同?各有什么用处? 首先可以观察源码: eg:torch.nn.Conv2d CLASS t
阅读全文
摘要:实现一个定制的 Dataset 类 Dataset 类是 PyTorch 图像数据集中最为重要的一个类,也是 PyTorch 中所有数据集加载类中应该继承的父类。其中,父类的两个私有成员函数必须被重载。 getitem(self, index) 支持数据集索引的函数 len(self) 返回数据集的
阅读全文
摘要:DataLoader DataLoader 是 PyTorch 中读取数据的一个重要接口,该接口定义在 dataloader.py 文件中,该接口的目的: 将自定义的 Dataset 根据 batch size 的大小、是否 shuffle 等封装成一个 batch size 大小的 Tensor,
阅读全文
摘要:torch.max() Explation: Returns the maximum value of all elements in the input tensor Example: Explation: Returns a namedtuple where is the maximum
阅读全文
摘要:Main operation categories that encompass the operations of tensors. 1. "Reshaping operations " 2. "Element wise operations " 3. "Reduction operations
阅读全文
摘要:Reshapeing operations Suppose we have the following tensor: We have two ways to get the shape: The rank of a tensor is equal to the length of the tens
阅读全文
摘要:Reuction operations Reduction operations A reduction operations on a tensor is an operation that reduces the number of elements contained within the t
阅读全文
摘要:Access operations Accessing elements inside tensors Suppose we have the following tensors: Do it with multiple values:
阅读全文
摘要:Element wise operations An element wise operation operates on corresponding elements between tensors. Two tensors must have the same shape in order to
阅读全文
浙公网安备 33010602011771号