说明:
a向量有m个点,b向量有n个点,计算a中每一个点与b中所有点的距离,并用阈值筛选出大于某个值的个数,求平均值
debug
用pytorch进行矩阵运算时出现如下错误,原因是索引超出范围
lymph_num += len(dist[dist < 500])#代码行
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
原因是因为索引超出范围
完整代码
import pandas as pd
import numpy as np
import os
from itertools import chain
import h5py
from tqdm import tqdm
from glob import glob
from scipy.io import loadmat
import torch.nn.functional as F
import torch
Mat_path = '/media/hero/fengzy/TO_FeiHu_MAT'
out_put = './out_put'
h5_path = '/home/hero/disk/ubuntu_free/Hou_feihu/out_put/h5_file'
def save_hdf5(output_path, asset_dict, attr_dict= None, mode='a'):
file = h5py.File(output_path, mode)
for key, val in asset_dict.items():
# data_shape = val.shape
try:
data_shape = val.shape
except:
import pdb
pdb.set_trace()
if key not in file:
data_type = val.dtype
chunk_shape = (1, ) + data_shape[1:]
maxshape = (None, ) + data_shape[1:]
dset = file.c