- 博客(9)
- 资源 (21)
- 收藏
- 关注
原创 Pytorch数据读取加速方法
1. 方法一:使用prefetcherclass data_prefetcher(): def __init__(self, loader): self.loader = iter(loader) self.stream = torch.cuda.Stream() self.mean = torch.tensor([0.485 * 255, 0.456 * 255, 0.406 * 255]).cuda().view(1,3,1,1)
2020-08-20 10:38:23 22221 4
原创 Pytorch 模型查看参数
def count_parameters(model): return sum(p.numel() for p in model.parameters() if p.requires_grad)print("模型的参数量", count_parameters(model))print("model",model)from torchsummary import summaryprint(summary(model, (input_data.shape[1])))...
2020-08-18 17:34:40 1485
原创 python sys.getsizeof 变量的大小
# 671MBa=np.ones(shape=(2000,44000),dtype=np.float)import syssys.getsizeof(a)/1024/1024
2020-08-18 11:24:06 2895
原创 两种背包问题(递归,python)
书包容量为 C, 每个物品对应重量wi和 vi ,求可拥有的最大价值,每个商品只有一个。递归解决:def backage(C,weight_list,value_list,now_value): # 剩下容量,目前商品,目前的价格,目前拥有的价值 if C<=0 or len(weight_list) ==0: return now_value if C < min(weight_list): return now_value
2020-08-13 20:55:35 9120
原创 Pytorch cannot allocate memory 解决内存不足问题
del X_train, y_train, X_valid, y_validgc.collect()torch.cuda.empty_cache()# torch.cuda.clear_memory_allocated() # entirely clear all allocated memory
2020-08-08 13:20:45 5448
原创 numpy含nan值进行归一化操作
1. 方法一import numpy as npA = np.array([[ 7, 4, 5, 7000], [ 1, 900, 9, nan], [ 5, -1000, nan, 100], [nan, nan, 3, 1000]])#Compute NaN-normsL1_norm = np.nansum(np.abs(A), axis=1)L2_norm =
2020-08-07 17:34:28 1367
原创 Pytorch学习率调整策略StepLR
CLASStorch.optim.lr_scheduler.StepLR(optimizer, step_size, gamma=0.1, last_epoch=-1, verbose=False)>>> # lr = 0.05 if epoch < 30>>> # lr = 0.005 if 30 <= epoch < 60>>> # lr = 0.0005 if 60 <= epoch < 90
2020-08-07 06:55:41 14772
原创 Python决策树的可视化
# Fit the classifier with default hyper-parametersclf = DecisionTreeClassifier(random_state=1234)model = clf.fit(X, y)text_representation = tree.export_text(clf)print(text_representation)from dtreeviz.trees import dtreeviz # remember to load the pack
2020-08-06 17:46:29 3793 2
原创 GLU, sparsemax, GELU激活函数
2. sparsemaxSoftmax:softmax缺点:每个向量位置都有值。文章From Softmax to Sparsemax:A Sparse Model of Attention and Multi-Label Classification 提出了能够输出稀疏概率的Sparsemax。这里把输入 z 和某个分布 p 的欧式距离最小化。一种具体的实现是,参考:论文;...
2020-08-06 14:54:34 13889
python程序设计(浙江大学).rar
2020-10-22
生成对抗网络画猫python
2018-12-25
深度卷积生成对抗网络TensorFlow代码实现
2018-12-25
深度学习与自然语言处理
2018-12-13
python qt gui快速编程PyQt编程指南 pdf扫描版及随书源代码源码.zip
2018-03-04
MySQL编译文件直接下载安装mysqlclient-1.3.7-cp35-none-win_amd64.whl
2018-01-28
Python for Probability,Statistics,and Machine Learning.pdf
2018-01-11
TensorFlow_ Large-Scale Machine Learning
2017-12-17
数据结构基础期末考试 2005-2012.7z
2017-12-09
小波变换详解及应用2页PPT
2017-11-27
C++编写的图书馆管理系统
2017-11-22
arduinoTimerOneLibrary_v1.1.0
2017-11-08
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人