python
silhouette10
这个作者很懒,什么都没留下…
展开
-
Pycharm无法识别自己写的包的解决办法Unresolved reference ‘XXX‘
错误:Unresolved reference ‘embedding’将你需要引用的文件夹的上级目录标记为:Sources Root假设目录结构如下,则应该将src文件夹标记为Sources Root,而不是将embedding文件夹标记为Sources Root。具体操作:点击Mark Directory as–>Sources Root参考:https://blog.csdn.net/LMFranK/article/details/101161431...原创 2022-05-04 15:47:47 · 1019 阅读 · 0 评论 -
Sample larger than population or is negative
原文的出错地方为:return {train_label: random.sample(sentences, nc) for train_label, sentences in train_label_to_sentences.items()}出错的地方是 random.sample(sentences, nc) ,就是sentence中可能没有nc个句子以供随机选择。自己选取的数据集是一个高度不平衡的数据集,有的类别含有的训练数量只有个位数。...原创 2022-01-28 16:19:20 · 1169 阅读 · 0 评论 -
IndexError: string index out of range
IndexError: string index out of range今天跑代码时候发现这个错误,奇怪的是代码跑昨天的数据集还是没有问题的,今天换了一个数据集就会报这个错误。1,不是网上那种索引溢出的问题,比如索引是0-9,你却搜索的是102,看了一下自己完整的错误,在索引0的时候就错了,则有可能是数据集中存在空字符串导致。将数据集中空字符串删除,则问题解决。if clean_line[0] == ' ': IndexError: string index out of range...原创 2022-01-27 20:42:09 · 8425 阅读 · 0 评论 -
str和list相互转换,在字典中添加元素,交换字典中键值对的位置
str和list相互转换:https://www.jb51.net/article/142644.htm在字典中添加元素:https://www.jb51.net/article/196873.htm原创 2022-01-07 23:38:20 · 360 阅读 · 0 评论 -
KL-Divergence,三元组损失
KL Divergence:https://zhuanlan.zhihu.com/p/95687720三元组损失:https://blog.csdn.net/zenglaoshi/article/details/106928204原创 2022-01-06 16:57:19 · 96 阅读 · 0 评论 -
Resource wordnet not found. ; [nltk_data] Error loading wordnet: <urlopen error [Errno 11004]
nltk_data --wordnet1. Resource wordnet not found.Please use the NLTK Downloader to obtain the resource:2. [nltk_data] Error loading wordnet: 1. Resource wordnet not found.Please use the NLTK Downloader to obtain the resource:错误1:Resource wordnet not foun原创 2022-01-03 21:13:32 · 4042 阅读 · 5 评论 -
今日问题待解决(2022.1.3)
1.Some weights of the model checkpoint at bert-base-uncased were not used when initializing BertModel:2.BertModel.from_pretrained(‘bert-base-uncased’)3.PyTorch中的ModuleList和Sequential参考:https://zhuanlan.zhihu.com/p/75206669nn.Sequential:1 nn.Sequential原创 2022-01-03 17:23:35 · 1149 阅读 · 0 评论 -
error: Microsoft Visual C++ 14.0 is required. Get it with “Build Tools for Visual Studio“: https://v
安装fasttext首先利用pip install fasttext出现错误error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/此时可以利用安装组件进行安装:在此网址找到fasttext注意看版本cp后面表示Python的版本 amd后面表示操作系统位数(我的是Python3.原创 2022-01-03 16:33:09 · 1542 阅读 · 0 评论 -
np.random.beta();np.random.permutation()
只用来记录自己学习np.random.beta:参考https://www.cnblogs.com/kuangmeng/p/15727345.htmlnumpy.random.beta(a,b,size=None)从β分布中提取样本。β分布是狄里克莱分布的一个特例,与伽马分布有关。在这里我们将参数(3个参数)设置为32 32 3参数1:32次正面。参数2:32次反面。参数3:总共进行3次。 按照惯例来说,我们正反面的次数一致的话,概率应该也是0.5。 在这里我们可以看到β分布下,概率值是0.原创 2022-01-01 21:57:34 · 4710 阅读 · 0 评论 -
Unresolved reference ‘utils‘
from utils import common我在导入自己写的包的.py文件的时候,报错:Unresolved reference ‘utils’首先,我按照网上百度的:在pycharm中设置source路径file–>setting–>project:server–>project structure-->选择python(工程名)-->点击Sources图标-->Apply即可将放package的文件夹设置为source,这样import的模块类等,就是通原创 2021-12-31 15:20:50 · 3553 阅读 · 4 评论 -
anaconda创建虚拟环境
参考:https://www.cnblogs.com/memento2233/p/10357681.html指定路径:https://blog.csdn.net/learn_tech/article/details/80748450原创 2021-12-21 21:56:17 · 601 阅读 · 0 评论 -
ModuleNotFoundError: No module named ‘transformers.modeling_gpt2‘
运行代码发现错误如下:解决:将导入模块from transformers.modeling_gpt2 import GPT2LMHeadModel改为:from transformers.models.gpt2.modeling_gpt2 import GPT2LMHeadModel原创 2021-12-21 14:33:26 · 5184 阅读 · 1 评论 -
nn.Parameter()
参考笔记:https://www.cnblogs.com/xiaoqing-ing/category/1999823.htmlhttps://blog.csdn.net/echo_gou/category_11251120.html沐神提供的:https://courses.d2l.ai/zh-v2/1、W1 = nn.Parameter( torch.randn(num_inputs, num_hiddens, requires_grad=True) * 0.01)nn.Paramet原创 2021-09-21 20:59:38 · 1123 阅读 · 2 评论 -
UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach()
1、UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).解决:将theta_init_new = torch.tensor(theta, dtype=torch.fl原创 2021-09-17 22:01:25 · 11633 阅读 · 1 评论