- 博客(126)
- 收藏
- 关注
原创 average_duration = (average_duration = (num_frames - self.skip_length + 1) + 1) // self.num_segments
ddd
2022-10-30 22:05:40
260
原创 cv::ColorMap only supports source images of type CV_8UC1 or CV_8UC3 in function
CV_8uc1 单颜色通道 8位
2022-09-24 14:56:42
1657
原创 ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。
gg
2022-09-18 14:56:17
1994
1
原创 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
545
原创 CNN+SVM
问题:到底能不能使用CNN和SVM一起来实现端对端训练呢?答:查到的好像是可以,参考文献如下:https://arxiv.org/abs/1306.0239文中说使用L2 SVM下面这个链接也有说明怎么使用,大概意思就是把最后一层的FC当作SVM和CNN一起训练,即设置个损失函数就ok了https://blog.youkuaiyun.com/ying86615791/article/details/71366184?spm=1001.2101.3001.6650.1&utm_medium=dist
2022-05-23 09:05:27
1483
原创 nn.gru
不管是否有batch_first=True,hidden的输出都是[bidrection*num_layers,batchsize,hidden]
2022-05-12 20:54:56
253
原创 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
557
原创 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
3540
原创 切片问题啊
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
143
原创 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
904
原创 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
350
原创 元组的拼接
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
481
原创 报错command not found
总是报错command not foundgit下sh xx.sh刚开始以为代码有问题,后来发现原来就是把它前面那行注释了,这莫名其妙的报错,,,
2022-03-20 22:00:35
410
原创 不平衡样本分类指标
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
273
原创 混淆矩阵 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
1128
原创 net.layer.children
import pretrainedmodelsbase_model='resnet101'base_model=pretrainedmodels.__dict__[base_model](num_classes=1000,pretrained='imagenet')n_segment_list=[n_segment]*4isinstance(base_model,torchvision.models.ResNet) # Truestage=net.layer1blocks=list(stage.
2022-03-16 20:03:58
183
原创 accuracy的计算
torch.max(torch.nn.functional.softmax(outputs), 1)上面的输出为两个,第一维是概率,第二维是索引,因此如果想用from sklearn.metrics import accuracy_score计算准确率的话,需要取出索引即[1]
2022-03-12 18:54:16
699
原创 环境配置问题
torch官网没有的cuda和torch版本,那就是真的没有,安装时候一定要指定cuda,否则会自己安装,但是和自己的cuda不匹配命令nvcc -V查看的cuda版本为10.1,torch1.1环境里print(torch.version.cuda)输出为10.0,但是代码可以跑...
2022-03-05 16:34:07
432
原创 22.3.4记录
1 conda安装pytorchvideo,装了半天装不上,换成pip就行了2 https://blog.youkuaiyun.com/yu876876/article/details/79656422用wget获取链接不安全,在链接前面加上 --no-check-certificate就行了3 jupyter添加核https://www.cnblogs.com/shanger/p/12006322.html这个是在jupyter内进行的在终端#安装ipykernelpip install ip
2022-03-04 21:57:43
729
原创 nn.CrossEntropyLoss
刚开始报错TypeError: forward() got an unexpected keyword argument 'reduction'查了半天后发现是写错地方了,原来是这么写的criterion = nn.CrossEntropyLoss(weight=weights)loss = criterion(x, y, reduction='sum')基本功不扎实真的被自己笑死,修改后criterion = nn.CrossEntropyLoss(weight=weights, redu
2022-03-04 18:07:13
1213
4
原创 在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
1375
原创 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
802
原创 将变量写入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
473
原创 tensorboard的使用
https://www.cnblogs.com/ipersevere/p/10843115.html这个链接里面有说明注意cmd要在log文件夹下打开,而不是在log.txt所在文件夹打开
2022-01-21 22:38:06
97
原创 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
2659
原创 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
333
原创 ModuleNotFoundError: No module named ‘non_local‘
报错如题目,相应文件夹下面也有init文件,但是就是不行,然后发现init里面import时候都是前面有个点,加上了后果然可以了
2022-01-06 09:52:52
307
原创 关于pydicom参数说明
[::4]#每4个取一个https://dicom.innolitics.com/ciods/us-multi-frame-image/cine/00180040ds=dicom.read_file("xxx.dcm")ds.CineRate 帧率ds.EffectiveDuration 时长(sec)ds.PhotometricInterpretation 颜色空间编码(是字符串)ds.NumberOfFrames 帧数 ds=dicom.read_file("xxx.dcm")
2021-12-10 18:23:05
343
原创 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
791
原创 2021-11-02 关于环境配置一些列问题
首先,不要因为显卡新就买,有时候还是经典的好nvidia-smi和nvcc -V这两个命令出来的cuda版本不一致,要以nvcc -V为准以后再记录
2021-11-02 11:56:31
111
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人