![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
仅用于个人纪录
这个作者很懒,什么都没留下…
展开
-
average_duration = (average_duration = (num_frames - self.skip_length + 1) + 1) // self.num_segments
ddd原创 2022-10-30 22:05:40 · 203 阅读 · 1 评论 -
list out of range
ddd原创 2022-09-26 11:46:01 · 543 阅读 · 0 评论 -
cv::ColorMap only supports source images of type CV_8UC1 or CV_8UC3 in function
CV_8uc1 单颜色通道 8位原创 2022-09-24 14:56:42 · 1519 阅读 · 0 评论 -
labelme相关 :修改mask颜色,转为二值
在\anaconda\envs\labelme\Lib\site-packages\imgviz 下打开label.py文件,修改为 for i in range(0, n_label): id = i r, g, b = 0, 0, 0 for j in range(0, 8): if i == 1: r = 255 g = 255原创 2022-05-31 14:35:04 · 450 阅读 · 0 评论 -
CNN+SVM
问题:到底能不能使用CNN和SVM一起来实现端对端训练呢?答:查到的好像是可以,参考文献如下:https://arxiv.org/abs/1306.0239文中说使用L2 SVM下面这个链接也有说明怎么使用,大概意思就是把最后一层的FC当作SVM和CNN一起训练,即设置个损失函数就ok了https://blog.csdn.net/ying86615791/article/details/71366184?spm=1001.2101.3001.6650.1&utm_medium=dist原创 2022-05-23 09:05:27 · 1363 阅读 · 0 评论 -
nn.gru
不管是否有batch_first=True,hidden的输出都是[bidrection*num_layers,batchsize,hidden]原创 2022-05-12 20:54:56 · 187 阅读 · 0 评论 -
GRU实战双向
import torchimport torch.nn as nnimport torch.optim as optimimport csvfrom torch.utils.data import Datasetfrom torch.utils.data import DataLoaderimport numpy as npimport matplotlib.pyplot as pltimport timefrom torch.nn.utils.rnn import pack_padded原创 2022-05-10 14:50:58 · 471 阅读 · 0 评论 -
AttributeError: ‘tuple‘ object has no attribute ‘size‘,AttributeError: ‘function‘ object has no attr
旧的summary加入LSTM之类的会报错,需要用新的summarrypip install torchinfo使用方法from torchinfo import summary model = Resnet(basic_block, [2, 2, 2, 2], 16).cuda()batch_size = 16summary(model, input_size=(batch_size, 1, 28, 28))...原创 2022-05-09 11:29:40 · 3316 阅读 · 0 评论 -
切片问题啊
a = np.array([[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], [[13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]], [[25, 26, 27, 28], [29, 30, 31, 32], [33, 34, 35, 36]], ])print(a.shape) # (3, 3, 4)b=a[:,-1,:原创 2022-05-08 16:34:36 · 104 阅读 · 0 评论 -
GRU输入和输出
https://www.cnblogs.com/ryukirin/p/14587520.html感觉不太对#num_layers#可以看到,x就还是`(batch_size,seq,input_size=)`的形式,要设置为batch_first=Trueimport torch.nn as nnimport torchx = torch.rand(10,24,100)#torch.nn.lstm(input_size=100,hidden_size=16,num_layers=2)#输原创 2022-05-08 15:34:41 · 803 阅读 · 0 评论 -
nn.squential中添加reshape和GRU
都需要自己定义一个GRUclass SelectItem(nn.Module): def __init__(self, item_index): super(SelectItem, self).__init__() self._name = 'selectitem' self.item_index = item_index def forward(self, inputs): return inputs[self.item原创 2022-05-08 11:14:46 · 286 阅读 · 0 评论 -
元组的拼接
import torchv1 = torch.range(1, 32).view(16,2) print(v1.size())print(v1.size()[1:])v2 = v1.view((-1, 2)+v1.size()[1:]) print(v2.size())print((-1,8)+torch.Size([2]))print(type((-1,1)))print(type((3,)))print((-1,8)+(3,))输出torch.Size([16, 2])tor原创 2022-04-13 15:11:27 · 432 阅读 · 0 评论 -
resnet的讲解
https://zhuanlan.zhihu.com/p/353235794?ivk_sa=1024320u原创 2022-04-06 15:40:13 · 130 阅读 · 0 评论 -
报错command not found
总是报错command not foundgit下sh xx.sh刚开始以为代码有问题,后来发现原来就是把它前面那行注释了,这莫名其妙的报错,,,原创 2022-03-20 22:00:35 · 349 阅读 · 0 评论 -
不平衡样本分类指标
MCC>F1from sklearn.metrics import confusion_matrixfrom sklearn.metrics import f1_score, recall_score, accuracy_score, precision_scoredef calc(TN, FP, FN, TP): SN = TP / (TP + FN) # recall SP = TN / (TN + FP) # Precision = TP / (TP + FP)原创 2022-03-19 21:48:39 · 244 阅读 · 0 评论 -
混淆矩阵 confusion_matrix
sklearn中的混淆矩阵源码 >>> tn, fp, fn, tp = confusion_matrix([0, 1, 0, 1], [1, 1, 1, 0]).ravel() >>> (tn, fp, fn, tp) (0, 2, 1, 1)所以混淆矩阵输出为TN FPFN TP这个和在网上查的不一样,要注意...原创 2022-03-19 17:47:32 · 1080 阅读 · 0 评论 -
click一直报错functional has ,,,‘name
发现原来是在run()之前加了个函数,这个bug找了一天原创 2022-03-15 18:37:46 · 158 阅读 · 0 评论 -
accuracy的计算
torch.max(torch.nn.functional.softmax(outputs), 1)上面的输出为两个,第一维是概率,第二维是索引,因此如果想用from sklearn.metrics import accuracy_score计算准确率的话,需要取出索引即[1]原创 2022-03-12 18:54:16 · 646 阅读 · 0 评论 -
ViViT讲解
https://jishuin.proginn.com/p/763bfbd7081a原创 2022-03-01 16:15:23 · 850 阅读 · 0 评论 -
在keras的Conv2D加入LSTM
https://www.pythonheidong.com/blog/article/146429/31d9cd672b75340c276b/https://github.com/wushilian/CRNN_Attention_OCR_Chinese/blob/master/model.py要在LSTM之前加入reshape,并且LSTM后不需要加入flatten层原创 2022-02-16 20:09:22 · 1276 阅读 · 0 评论 -
keras输出某一层维度
BATCH_SIZE = 2 (just try)TIME_STEPS=frame_num (=86)INPUT_SIZE=pixel_num (=28*28)model = Sequential()model.add(InputLayer(batch_input_shape=(BATCH_SIZE, TIME_STEPS, INPUT_SIZE)))print (model.output_shape)model.add(TimeDistributed(Conv2D(64,(1,3原创 2022-02-16 19:37:21 · 763 阅读 · 0 评论 -
将变量写入txt文件
实现目标:将所有不能处理的文件名称写入txt中 try: zzz = df.loc[pID,['子文件夹名称']].tolist()[0] except: IDs.append(pID) for i, (cat, idx) in enumerate(data.items()): assert i == int(idx) # make sure the rank is right categories.append(原创 2022-01-26 22:00:56 · 412 阅读 · 0 评论 -
tensorboard的使用
https://www.cnblogs.com/ipersevere/p/10843115.html这个链接里面有说明注意cmd要在log文件夹下打开,而不是在log.txt所在文件夹打开原创 2022-01-21 22:38:06 · 64 阅读 · 0 评论 -
TSM数据密集采样,稀疏采样和二次采样
https://www.freesion.com/article/22801370967/密集采样def _sample_indices(self, record): if self.dense_sample: # i3d dense sample # 密集随机采样 sample_pos = max(1, 1 + record.num_frames - 64) t_stride = 64 // self.num_segments start_id原创 2022-01-07 15:13:35 · 2522 阅读 · 0 评论 -
tqdm无法单行显示
tqdm显示Loss 1.2855 (1.1737) Prec@1 15.625 (56.497) Prec@5 100.000 (100.000): 90%|███████████▊ | 38/42 [01:32<00:02, 1.40it/Loss 2.4410 (1.2062) Prec@1 6.250 (55.208) Prec@5 100.000 (100.000): 90%|████████████▋ | 38/42 [01:33<00:02, 1.40原创 2022-01-06 19:51:24 · 267 阅读 · 0 评论 -
ModuleNotFoundError: No module named ‘non_local‘
报错如题目,相应文件夹下面也有init文件,但是就是不行,然后发现init里面import时候都是前面有个点,加上了后果然可以了原创 2022-01-06 09:52:52 · 261 阅读 · 0 评论 -
2021-11-08RuntimeError: Expected object of device type cuda but got device type cpu for argument #3
报错RuntimeError: Expected object of device type cuda but got device type cpu for argument #3 'weight' in call to _thnn_nll_loss_forward报错思路功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTe原创 2021-11-08 16:23:06 · 749 阅读 · 0 评论 -
2021-11-02 关于环境配置一些列问题
首先,不要因为显卡新就买,有时候还是经典的好nvidia-smi和nvcc -V这两个命令出来的cuda版本不一致,要以nvcc -V为准以后再记录原创 2021-11-02 11:56:31 · 80 阅读 · 0 评论 -
pytorch is not compiled with NCCL supoort
真烦人原创 2021-11-01 20:18:03 · 3080 阅读 · 3 评论 -
一系列-记帮lj搞东西
1、首先在ubuntu下创建一个python2.7的环境一直搞不上,后来发现gedit ~./condarc调出来命令,然后就会发现把里面的镜像源全部删除,只留下defaults就行了,啊,死马当活马医真的能医好哦2、win远程连接ubuntu调出命令行ssh Dell@ip地址或者在vscode那里安装一下ssh扩展,然后ctrl+shift+p,调出来后按照提示连接就行...原创 2021-10-26 13:44:15 · 73 阅读 · 0 评论 -
cuda不可用
震惊!原因竟然是没有加括号!原创 2021-10-12 21:01:11 · 426 阅读 · 0 评论 -
“SyntaxError: invalid syntax”
还有可能是名字第一个是数字,而不是字母1PatientFolder ="D:/"这个以1开头就不行原创 2021-09-16 13:42:01 · 131 阅读 · 0 评论 -
@click.command
# hello.pyimport click@click.command()@click.option('--count', default=1,help='Number of greetings.')#prompt='Conut', @click.option('--name', prompt='Your name', help='The person to greet.')#def hello(count, name): """Simple program原创 2021-08-18 11:24:05 · 614 阅读 · 1 评论 -
关于python的小错误
for index,pID in enumerate(patientIDs): print(pID) patient_path = Path(pID, 'DICOM') videos = [ x for x in patient_path.iterdir() ] max_video = find_max_index(videos) mv_to_path = Path('only_CE',pID) if not mv_to_path.exists(): mv_to_path.mkdi原创 2021-06-07 21:44:51 · 50 阅读 · 0 评论 -
NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver.
https://zhuanlan.zhihu.com/p/337013545原创 2021-05-22 12:31:40 · 51 阅读 · 0 评论 -
特征空间池化 SPP
这个是原文章,觉得讲得很好import mathimport torchimport torch.nn.functional as Fclass SPPlayer(torch.nn.Module): def __init__ = (self,num_levels,pool_type='max_pool'): super( SPPLayer ,self).__init__() self.num_levels = num_levels s原创 2021-05-13 18:35:53 · 131 阅读 · 0 评论 -
OpenCV2的VideoCapture保存视频0kb问题
out = cv2.VideoWriter(video_filename, fourcc, fps, (400,500))为什么只有大小是长宽相同的才可以写进去应该是缺少什么东西?https://answers.opencv.org/question/100979/outputavi-file-created-but-its-size-is-0k/这个应该也是一个解决方法...原创 2021-04-30 20:37:45 · 351 阅读 · 1 评论 -
np.pad()
import numpy as nparray = np.array([[1, 1],[2,2]])"""((1,1),(2,2))表示在二维数组array第一维(此处便是行)前面填充1行,最后面填充1行; 在二维数组array第二维(此处便是列)前面填充2列,最后面填充2列constant_values=(0,3) 表示前面的填充0,后面的填充3"""ndarray=np.pad(array,((2,1),(2,2)),'constant', constan原创 2020-12-15 20:26:18 · 62 阅读 · 0 评论 -
知识蒸馏和迁移学习
这个是链接原创 2020-12-08 21:04:39 · 1147 阅读 · 0 评论 -
matplotlib显示不出图片的问题
总是有奇奇怪怪的问题#display the imageplt.imshow(image)plt.show()原创 2020-12-03 21:55:10 · 850 阅读 · 0 评论