python
wanzi_antang
每天进步一点点
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
GPU类型数据与CPU类型数据转换
GPU和CPU使用数据之间切换原创 2022-09-12 16:33:17 · 1026 阅读 · 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 · 1650 阅读 · 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.youkuaiyun.com/herimorisome/article/details/7636567**...原创 2021-03-19 16:10:45 · 172 阅读 · 0 评论 -
程序小记
记录一下,如何在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 · 204 阅读 · 0 评论 -
终端命令保存
终端提示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 · 1646 阅读 · 0 评论 -
安装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 · 5464 阅读 · 8 评论 -
ubunt下终端激活环境命令
source ~/anaconda3/etc/profile.d/conda.shconda activate myenvpip install tensorflow==1.13.1原创 2020-03-19 22:26:08 · 1258 阅读 · 0 评论 -
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 · 170 阅读 · 0 评论 -
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 · 857 阅读 · 0 评论 -
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 · 1384 阅读 · 1 评论 -
书写.sh文件在终端运行
需要运行文件 train_model.py!/bin/bashpython -u train_model.py原创 2020-02-09 15:49:39 · 483 阅读 · 0 评论 -
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 · 829 阅读 · 0 评论 -
tensorflow 安装以及查看
pythonimport tensorflow as tf>>> tf.__version__'1.13.1'原创 2020-01-18 22:17:21 · 148 阅读 · 0 评论 -
导入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 · 1965 阅读 · 0 评论 -
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 · 1193 阅读 · 0 评论 -
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 · 727 阅读 · 0 评论 -
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 · 1855 阅读 · 0 评论 -
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 · 1212 阅读 · 0 评论 -
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 · 1007 阅读 · 0 评论
分享