自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(34)
  • 资源 (1)
  • 收藏
  • 关注

原创 GPU类型数据与CPU类型数据转换

GPU和CPU使用数据之间切换

2022-09-12 16:33:17 874 1

原创 tf预训练模型转换为torch预训练模型

在将albert的tensorflow预训练模型转换为 torch类型预训练模型,踩了很多坑。终于解决,希望对大家有用前期准备创建一个环境带有torch和tf的环境,步骤如下:首先创建环境python conda create -n torchtf_env python=3.7然后,安装torch(根据自己电脑的cuda安装)python conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c co

2021-03-19 18:28:36 1476 1

原创 命令记录(二)

linux下.tar.gz如何解压**解压缩:tar -zxvf archive_name.tar.gz上面这个解包命令将会将文档解开在当前目录下面。当然,你也可以用这个命令来捏住解包的路径:tar -zxvf archive_name.tar.gz -C /tmp/extract_here/df -h 查看linux 磁盘大小 以m来显示原文链接:https://blog.csdn.net/herimorisome/article/details/7636567**...

2021-03-19 16:10:45 107

原创 程序小记

记录一下,如何在torch中进行单个batch计算batch_size = x.shape[0]seq_len = x.shape[1] emo_induce = emo_induce.cpu().numpy() #aspect开始和结束的位置text_len = x_len.cpu().numpy() #传入子句的真实长度emo_weight = [[] for i in range(batch_size)]context_weight = [[] for i in range(batch_

2021-03-10 20:58:33 117

原创 好的关系抽取的讲解网址

https://zhuanlan.zhihu.com/p/77868938

2020-08-07 21:34:24 93

原创 终端命令保存

终端提示no condasource ~/.bashrc激活之后终端运行代码:一种方式:CUDA_VISIBLE_DEVICES=0 python -u run_bert_crf_en.py --Gpu_num 0 > ./results_file/run_bert_crf_en_0.log 2>&1 &CUDA_VISIBLE_DEVICES=1 python -u run_bert_crf_en.py --Gpu_num 1 > ./results_fil

2020-07-24 21:54:49 1492

原创 RuntimeError: cuDNN error: CUDNN_STATUS_BAD_PARAM

RuntimeError: cuDNN error: CUDNN_STATUS_BAD_PARAM这个错误是由于数据类型不一致造成的:x_emb=self.gen_embedding(x) #[83, 8, 300] max_len, batch, dimx_emb=self.dropout(x_emb)x_emb = x_emb.to(torch.float32)total_length = x_emb.size(0) #句子的最大长度packed_emb=torch.nn.utils.rn

2020-07-05 22:21:23 6985 1

原创 安装transformer失败

出现问题 Building wheel for tokenizers (PEP 517) ... error ERROR: Command errored out with exit status 1: command: /anaconda3/envs/torchenv/bin/python /anaconda3/envs/torchenv/lib/python3.7/site-pac...

2020-05-07 14:28:16 5009 8

原创 训练词向量

import gensimimport pickle'''load the pkl files'''def loadList(path): pkl_file = open(path, 'rb') segContent = pickle.load(pkl_file) pkl_file.close() return segContentdef train...

2020-03-29 09:37:33 173

原创 ubunt下终端激活环境命令

source ~/anaconda3/etc/profile.d/conda.shconda activate myenvpip install tensorflow==1.13.1

2020-03-19 22:26:08 1114

原创 pytorch学习(一)

- torch.nn.embedding >>> # an Embedding module containing 10 tensors of size 3>>> embedding = nn.Embedding(10, 3)>>> # a batch of 2 samples of 4 indices each>>&g...

2020-03-18 12:27:48 86

原创 python中list列表操作-过滤掉空元素, 打乱列表顺序

## 删除列表中的空字符a = ['', '好人','中国人']b = list(filter(None, a))print(b)[好人','中国人']#对列表打乱顺序>>> b = [1,3,5,7,8]>>> random.shuffle(b)>>> print(b)[5, 1, 8, 3, 7]...

2020-03-07 20:52:00 643

原创 python 加载json文件

读取json文件,并输出key是什么import jsonpath_example = r'/anaconda3/demo/work_new/bbnew/get_stand_data/dev-v1.1.json'with open(path_example, 'r') as load_f: load_dict = json.load(load_f) print(load_...

2020-03-06 09:15:42 1214 1

原创 python读取xml文件

针对下面xml样式,提取其中内容<emotionml category-set="http://www.w3.org/TR/emotion-voc/xml#big6" expressed-through="text" xmlns="http://www.w3.org/2009/10/emotionml"> <emotion id="0"> <categor...

2020-03-03 14:27:23 293

原创 unbunt 18 在使用overlea時出現指針定位不準確怎麼辦

更換瀏覽器,選用搜狐瀏覽器打開overleaf就可以了火狐瀏覽器安裝。在終端輸入:sudo apt-get install firefox然後輸入電腦密碼:

2020-02-27 16:51:14 109

原创 如何新建py文件时,自动添加头注释 pycharm(mac系统)

首先打开File --》Other settings ->Preference for New Projects…如图1然后按照图2 进行输入要显示的信息

2020-02-12 09:59:29 232

原创 书写.sh文件在终端运行

需要运行文件 train_model.py!/bin/bashpython -u train_model.py

2020-02-09 15:49:39 392

原创 从远程端下载文件到mac

下载文件p.pkl到文件./Downloads/`打开本地终端,不用登陆服务器:scp -r [email protected]:/home/dell./././/p.pkl ./Downloads/如果登陆了远程下载文件,需要知道自己本地计算机的ip地址...

2020-02-08 22:02:28 119

原创 DLL load failed: 找不到指定模块\Failed to load the native TensorFlow runtime解决方法

DLL load failed: 找不到指定模块\Failed to load the native TensorFlow runtime解决方法原因是:python 版本过高,可以尝试降低python版本,或者升高tf的版本pip install tensorflow-gpu== 1.15...

2020-01-19 15:16:00 713

原创 vscode中配置conda路径

在vscode中输入 conda显示:not found codaexport PATH=/home/name/anaconda3/bin:$PATHname处改为自己的目录

2020-01-19 15:09:33 2260 1

原创 tensorflow 安装以及查看

pythonimport tensorflow as tf>>> tf.__version__'1.13.1'

2020-01-18 22:17:21 86

原创 导入core_rnn_cell_impl 错误

ImportError: cannot import name 'core_rnn_cell_impl' from 'tensorflow.contrib.rnn.python.ops' (/Users/lxj/venv/lib/python3.7/site-packages/tensorflow/contrib/rnn/python/ops/__init__.py)解决办法:在tenso...

2020-01-18 22:13:43 1828

原创 pickle 存储列表为文件

'''save as list type'''import pickledef saveList(paraList, path): output = open(path, 'wb') # Pickle dictionary using protocol 0. pickle.dump(paraList, output) output.close()'...

2020-01-16 14:19:57 1099

原创 python中 filter函数的用法讲解

过滤掉不满足条件的信息>>> import math>>> def is_sqr(x):... return math.sqrt(x) % 1 == 0... >>> a = filter(is_sqr, range(1, 20))>>> print(a)<filter object at 0x10...

2020-01-13 17:04:42 588

原创 Python中使用Stanford CoreNLP 出现端点加载错误

from stanfordcorenlp import StanfordCoreNLPnlp = StanfordCoreNLP(r'/home/gld/stanford-corenlp-full-2016-10-31/', lang='zh')sentence = '清华大学位于北京。'print nlp.word_tokenize(sentence)print nlp.pos_ta...

2020-01-11 17:32:12 2003 2

原创 OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python p

在使用spacy进行语义分析时,一直出现加载包不成功的例子会出现:/Users/lxj/venv/bin/python /anaconda3/work_space_tree/ASGCN_master/dependency_graph.pyTraceback (most recent call last): File "/anaconda3/work_space_tree/ASGCN_m...

2020-01-10 20:32:45 11047

原创 python顺序执行多个py文件

import osos.system("python train_001.py 1>>log_001.txt")os.system("python train_002.py 1>>log_002.txt")os.system("python train_003.py 1>>log_003.txt")

2020-01-03 11:36:00 1723

原创 python读取xml文件

对于xml文件<weibo id="9685" emotion-type1="无" emotion-type2="无"><sentence id="1" opinionated="N">值得有关部门注意的是:大人要挟孩子乞讨可否按照治安条例进行处罚,或者屡教不改的,不然杜绝此类事件将遥遥无期,人大是否也该在法律层面进行探索,如果可以自食其力,而假装穷人乞讨也是一种欺诈啊...

2019-12-30 17:05:26 149

原创 获取两个字符串之间的内容的方法, 正则表达式 python re

比如获取 ‘beg_cause’ 与‘end_cause’之间的内容s = 'beg_cause#街拍交通安全#end_cause 小妹妹,这样坐单车真让人心悬啊,你还那么蛋定’a = r'beg_cause(.*?)end_cause'slotList = re.findall(a, s)print(slotList)out:['#街拍交通安全#']...

2019-12-30 16:32:57 12730 2

原创 codecs打开和存储文件(避免中文的乱码问题)

import codecs读取文件inputFile = codecs.open('datacsv_2105.csv', 'r','utf-8')写入文件outputFile1 = codecs.open('a.csv', 'w','utf-8')outputFile1.write(str(sentenceID) + ',' + str(index + 1) + ',' + k...

2019-12-30 11:04:13 662

原创 python 3: pickle加载数据出现UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 6: ordin

Traceback (most recent call last): File "/anaconda3/workspace_data/emoji_data/data/PsychExp/load_pk_file.py", line 27, in <module> datas = loadList(path) File "/anaconda3/workspace_data/...

2019-12-27 16:24:24 980

原创 TypeError: pred must not be a Python bool

TypeError: pred must not be a Python bool# 修改将('False' or 'True') 转换为tf.constant(False, dtype=tf.bool) 或者tf.constant(True, dtype=tf.bool)

2019-12-24 22:27:26 890

原创 各个研究任务的最新状态追踪

可以在下面网址中观察多个任务的进展状态,包括最佳的结果。极力推荐:https://paperswithcode.com/sota

2019-12-24 22:20:19 122

原创 python 获取文件夹路径的获取以及路径拼接的使用

import os# 获取当前文件目录base_path = os.path.dirname(__file__)# 获取当前文件下的out.txt的路径path = os.path.join(base_dir,'123.txt')

2019-12-24 22:10:16 1292

COAE2015_task1.zip

数据集是COAE2015评测中的任务:关于中文情感倾向型分析, 适合用于训练情感分析的模型。比如针对博文:哇塞,这里有好多绝版的照片,简直太赞了! 带有标签信息 positive

2019-12-26

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除