
pytorch
农民小飞侠
如果放弃了,那还谈什么理想
展开
-
[PaddlePaddle]HuggingFace上的Pytorch模型转PaddlePaddle模型示例
最近需要把HuggingFace上的Pytorch模型转换成Paddle的模型,总体思路是,只需要做一些小的映射就行了。下面我提供一个通用的示例,方便大家平时自己转模型和代码,主要思路就是对其中的Linear进行转置就可以了。有的人会说模型的代码需要怎么变呢?其实只需要把Torch对应的API替换成PaddlePaddle的API就行了,不用做过多的改变,注意一些写法的区别,可以参考文档。,可能不是很完善,如果没有找到对应的映射,就需要分别查torch和PaddlePaddle的文档进行比对了。原创 2023-05-21 08:24:18 · 602 阅读 · 0 评论 -
SapBERT: Self-alignment pretraining for BERT的代码使用示例
【代码】SapBERT: Self-alignment pretraining for BERT的代码使用示例。原创 2023-02-10 23:13:01 · 424 阅读 · 0 评论 -
【transformers】TypeError: div() got an unexpected keyword argument ‘rounding_mode‘
我的transformers的版本是4.2.4python版本是3.7torch版本是1.7搜了一下发现是我的torch版本太低,最低需要1.8。原创 2022-11-27 01:34:38 · 1814 阅读 · 0 评论 -
【fairseq】RuntimeError: Unrecognized tensor type ID: AutogradCUDA
今天在运行网上搜了一下可能是torch版本的原因,我的torch版本是torch-1.8.1+cu102。原创 2022-11-26 17:58:21 · 2035 阅读 · 0 评论 -
pyg Symbol not found: __ZN2at8internal13_parallel_runExxxRKNSt3__18functionIFvxxmEE
【代码】pyg Symbol not found: __ZN2at8internal13_parallel_runExxxRKNSt3__18functionIFvxxmEE。原创 2022-10-30 22:50:21 · 653 阅读 · 0 评论 -
pytorch terminate called after throwing an instance of ‘c10::HIPError‘
今天在跑PPO程序的时候,出现了下面的错误:terminate called after throwing an instance of 'c10::HIPError' what(): HIP error: hipErrorNoDeviceHIP kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.For debugging原创 2022-05-04 15:53:49 · 2647 阅读 · 0 评论 -
ubuntu 16.04 anaconda 切换清华的软件源安装pytorch
今天用anaconda安装pytorch的时候,发现安装的速度很慢,于是切换成了anaconda的软件源:conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/# 设置搜索时显示通道地址conda config --set原创 2021-12-18 19:09:51 · 1059 阅读 · 0 评论 -
python ModuleNotFoundError: No module named ‘torchsummary‘
今天在运行network in network程序的时候,出现了下面的错误:Traceback (most recent call last): File "load_premodel.py", line 7, in <module> from torchsummary import summaryModuleNotFoundError: No module named 'torchsummary'解决方法pip install torchsummary参考文献[已解原创 2021-07-06 08:40:34 · 5857 阅读 · 2 评论 -
AttributeError: module ‘torch‘ has no attribute ‘Assert‘
今天在运行TransGAN的时候出现了下面的错误: File "train_derived.py", line 6, in <module> import models_search File "/data/tianhao.lu/code/TransGAN/models_search/__init__.py", line 1, in <module> from models_search import ViT_custom_local544444_256_rp原创 2021-06-14 23:41:48 · 3625 阅读 · 0 评论 -
ImportError: cannot import name ‘IterableDataset‘ from ‘torch.utils.data.dataset‘
今天在导入torch库的时候出现了下面的错误:ImportError: cannot import name 'IterableDataset' from 'torch.utils.data.dataset'我的代码是:import jsonimport pandas as pdimport numpy as npimport torchimport torch.nn as nnimport torch.nn.functional as Ffrom torch.utils.data im原创 2021-06-09 19:56:16 · 4702 阅读 · 0 评论 -
AttributeError: module ‘torch.jit‘ has no attribute ‘_script_if_tracing‘
今天在运行torch程序的时候出现了下面的错误:AttributeError: module 'torch.jit' has no attribute '_script_if_tracing'解决方法pip install torchvision==0.5.0参考文献AttributeError: module ‘torch.jit’ has no attribute ‘_script_if_tracing’...原创 2021-06-08 23:35:01 · 3979 阅读 · 3 评论 -
pytorch动手实现skipgram模型
最近用pytorch实现了一下skipgram模型,代码参考了github哈,这里分享了我的实现:下载数据集import nltknltk.download('twitter_samples')from nltk.corpus import twitter_samples添加labellabel = "neg"neg_dataset = [(label, instance) for instance in twitter_samples.strings('negative_tweet原创 2021-05-02 18:19:36 · 599 阅读 · 0 评论 -
pytorch版本CSNet运行octa数据集的问题
今天跑了一下CSNet的pytorch的代码,https://github.com/suyanzhou626/CSNet发现跑octa数据集的时候,预测的输出是全黑色的,最后发现是代码里面的crop的问题,这里我把我修改的地方贴出来分享给大家:train.py基本没多大改动:"""Training script for CS-Net"""import osimport torchimport torch.nn as nnfrom torch import optimfrom torch原创 2021-04-28 23:34:46 · 884 阅读 · 10 评论 -
RuntimeError: expected device cuda:0 and dtype Byte but got device cuda:0 and dtype Bool
pytorch 运行的时候出现了下面的错误:loading 9423 train samples...loading 1048 dev samples...Traceback (most recent call last): File "train.py", line 170, in <module> main() File "train.py", line ...原创 2020-04-27 15:13:05 · 2088 阅读 · 0 评论 -
No CUDA runtime is found, using CUDA_HOME=‘/usr/local/cuda-10.0‘
今天在使用pytorch 跑pointnet++的时候,出现了下面的问题:No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda-10.0'/home/eric/anaconda3/lib/python3.6/site-packages/pointnet2_ops/pointnet2_utils.py:15: UserWarning: Unable to load pointnet2_ops cpp extension. JIT Comp原创 2020-05-13 21:09:08 · 26881 阅读 · 3 评论 -
bert transformers mask预测,预测缺失的mask字
今天需要用到transformer里面的bert进行mask预测,我这里分享一下我的代码:import torchfrom transformers import BertTokenizer, BertModel, BertForMaskedLM# OPTIONAL: if you want to have more information on what's happening, activate the logger as followsimport logginglogging.bas原创 2020-10-26 10:24:58 · 4940 阅读 · 6 评论 -
pytorch-pretrained-bert的模型下载慢的问题
今天需要用到pytorch-pretained-bert,但是下载预训练的模型花费了好长时间,这里来分享以下解决方法,其安装过程为:pip install pytorch-pretrained-bert如果调用BertModel等模型的时候,需要下载相应的预先训练模型,下载后的文件存放在cache文件夹:~/.pytorch_pretrained_bert/但是这个下载的过程我是等到...原创 2019-12-23 15:45:56 · 7219 阅读 · 2 评论 -
ModuleNotFoundError: No module named 'torchvision.models.detection'
今天在运行pytorch 的时候,出现了下面的错误:Traceback (most recent call last): File "train.py", line 14, in <module> from models.retinaface import RetinaFace File "/media/data/projects/faceDetect/Face-...原创 2019-11-13 22:30:14 · 30705 阅读 · 1 评论 -
ModuleNotFoundError: No module named 'torchnet'
今天在运行模型的时候出现了下面的问题,我的环境是python3, ubuntu 18.04:Traceback (most recent call last): File "main.py", line 10, in <module> import torchnet as tntModuleNotFoundError: No module named 'torchn...原创 2019-07-17 19:11:35 · 10489 阅读 · 0 评论