Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
如何在 Google Colab 上安装 PyTorch v1.0.0+?
PyTorch v1 0 0 稳定版是发布于 2018 年 12 月 8 日 https github com pytorch pytorch releases tag v1 0 0成为之后7个月前宣布 https code fb com
Pytorch
googlecolaboratory
Pytorch LSTM:计算交叉熵损失的目标维度
我一直在尝试在 Pytorch 中使用 LSTM LSTM 后跟自定义模型中的线性层 但在计算损失时出现以下错误 Assertion cur target gt 0 cur target lt n classes failed 我用以下函数
LSTM
Pytorch
onehotencoding
crossentropy
设置 torch.gather(...) 调用的结果
我有一个形状为 n x m 的 2D pytorch 张量 我想使用索引列表来索引第二个维度 可以使用 torch gather 完成 然后然后还设置新值到索引的结果 Example data torch tensor 0 1 2 3 4
python
Indexing
Pytorch
tensor
PyTorch 中的后向函数
我对 pytorch 的后向功能有一些疑问 我认为我没有得到正确的输出 import numpy as np import torch from torch autograd import Variable a Variable torch
machinelearning
Pytorch
gradientdescent
Autograd
带有填充掩码的 TransformerEncoder
我正在尝试使用 src key padding mask 不等于 none 来实现 torch nn TransformerEncoder 想象输入的形状src 20 95 二进制填充掩码的形状为src mask 20 95 填充标记的位置
Pytorch
transformermodel
attentionmodel
无法在jupyter笔记本中导入torch
系统 macOS 10 13 6 蟒蛇 3 7 蟒蛇3 我遇到麻烦时import torch在 jupyter 笔记本中 ModuleNotFoundError No module named torch 这是我安装 pytorch 的方法
python
jupyternotebook
Pytorch
PyTorch:运行时错误:函数 MulBackward0 在索引 0 处返回无效梯度 - 预期类型 torch.cuda.FloatTensor 但得到 torch.FloatTensor
我不明白这个错误告诉我什么 在另一个帖子 https github com NVIDIA flownet2 pytorch issues 139也解决了同样的问题 但没有有效的解决方案 Traceback most recent call
python
Pytorch
backpropagation
将 Pytorch 模型 .pth 转换为 onnx 模型
我有一个预训练的模型 其格式为 pth 扩展名 我想将其转换为 Tensorflow protobuf 但我没有找到任何方法来做到这一点 我见过 onnx 可以将模型从 pytorch 转换为 onnx 然后从 onnx 转换为 Tenso
python
tensorflow
deeplearning
Pytorch
PyTorch 中的标签平滑
我正在建造一个ResNet 18分类模型为斯坦福汽车使用迁移学习的数据集 我想实施标签平滑 https arxiv org pdf 1701 06548 pdf惩罚过度自信的预测并提高泛化能力 TensorFlow有一个简单的关键字参数Cr
python
machinelearning
Pytorch
transferlearning
PyTorch 中的数据增强
我对 PyTorch 中执行的数据增强有点困惑 现在 据我所知 当我们执行数据增强时 我们保留原始数据集 然后添加它的其他版本 翻转 裁剪 等 但 PyTorch 中似乎并没有发生这种情况 据我从参考文献中了解到 当我们使用data tra
python
imageprocessing
Dataset
Pytorch
dataaugmentation
PyInstaller 可执行文件无法获取 TorchScript 源代码
我正在尝试使包含 PyTorch 的脚本在 Windows 中可执行 我的脚本的导入是 import numpy core multiarray which is a workaround for ImportError numpy cor
python
Pytorch
pyinstaller
Pytorch RuntimeError:张量 a (4) 的大小必须与非单维 0 处张量 b (3) 的大小匹配
我使用的代码来自here https www learnopencv com image classification using transfer learning in pytorch 训练模型来预测印刷样式编号0 to 9 idx t
python
imageprocessing
ComputerVision
Pytorch
如何在pytorch中动态索引张量?
例如 我有一个张量 tensor torch rand 12 512 768 我得到了一个索引列表 说它是 0 2 3 400 5 32 7 8 321 107 100 511 我希望从给定索引列表的维度 2 上的 512 个元素中选择 1
python
deeplearning
Pytorch
torch
tensor
PyTorch 如何计算二阶雅可比行列式?
我有一个正在计算向量的神经网络u 我想计算关于输入的一阶和二阶雅可比矩阵x 单个元素 有人知道如何在 PyTorch 中做到这一点吗 下面是我项目中的代码片段 import torch import torch nn as nn class
python
Pytorch
gradient
如何从 PyTorch 模型的特定层获取输出?
如何从预训练的 PyTorch 模型 例如 ResNet 或 VGG 中提取特定层的特征 而无需再次进行前向传递 新答案 Edit torchvision v0 11 0 中有一个新功能 允许提取特征 https github com py
python
Pytorch
如何让火车装载机使用特定数量的图像?
假设我正在使用以下调用 trainset torchvision datasets ImageFolder root imgs transform transform trainloader torch utils data DataLoa
python
Pytorch
DataLoader
如何解决错误:PyTorch 中预期输入批量大小与目标批量大小不匹配?
我尝试通过 PyTorch 在 CIFAR10 数据集上创建逻辑模型 但是我收到错误 ValueError 预期输入batch size 900 与目标batch size 300 匹配 我认为正在发生的事情是 3 100 是 300 所以
python
machinelearning
deeplearning
Pytorch
使用 Huggingface 变压器仅保存最佳权重
目前 我正在使用 Huggingface transformers 构建一个新的基于 Transformer 的模型 其中注意力层与原始模型不同 我用了run glue py检查我的模型在 GLUE 基准测试上的性能 但是 我发现huggi
deeplearning
NLP
Pytorch
huggingfacetransformers
没有名为“torch”或“torch.C”的模块
希望得到像我 5 这样的解释 因为我已经检查了所有相关答案 但没有一个有帮助 我已经安装了Python 我已经安装了Pycharm 我已经安装了Anaconda 我已经安装了 Microsoft Visual Studio 我有not安装了
Pytorch
使用 CNN 和 pytorch 计算每个类别的准确度
我可以使用此代码计算每个时期后的准确性 但是 我想最后计算每个班级的准确性 我怎样才能做到这一点 我有两个文件夹 train 和 val 每个文件夹有 7 个不同类别的 7 个文件夹 train 文件夹用于训练 否则 val 文件夹用于测试
Pytorch
Classification
trainingdata
convneuralnetwork
loss
1
2
3
4
5
6
...100
»