hurst代码 python_Python numpy.spacing方法代码示例

本文详细介绍了Python中numpy.spacing方法的用途,并提供了22个代码示例,涵盖了该方法在不同场景下的应用,包括图像处理、深度学习、矩阵运算等多个方面。文章适合对numpy库感兴趣的读者,特别是需要理解和使用numpy.spacing方法的开发人员。
摘要由CSDN通过智能技术生成

本文整理汇总了Python中numpy.spacing方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.spacing方法的具体用法?Python numpy.spacing怎么用?Python numpy.spacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块numpy的用法示例。

在下文中一共展示了numpy.spacing方法的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: validate_cov_matrix

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import spacing [as 别名]

def validate_cov_matrix(M):

M = (M + M.T) * 0.5

k = 0

I = np.eye(M.shape[0])

while True:

try:

_ = np.linalg.cholesky(M)

break

except np.linalg.LinAlgError:

# Find the nearest positive definite matrix for M. Modified from

# http://www.mathworks.com/matlabcentral/fileexchange/42885-nearestspd

# Might take several minutes

k += 1

w, v = np.linalg.eig(M)

min_eig = v.min()

M += (-min_eig * k * k + np.spacing(min_eig)) * I

return M

开发者ID:gddingcs,项目名称:Dispersion-based-Clustering,代码行数:19,

示例2: MeanPixelAccuracy

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import spacing [as 别名]

def MeanPixelAccuracy(pred, label):

"""

Function to compute the mean pixel accuracy for semantic segmentation between mini-batch tensors

:param pred: Tensor of predictions

:param label: Tensor of ground-truth

:return: Mean pixel accuracy for all the mini-bath

"""

# Convert tensors to numpy arrays

imPred = np.asarray(torch.squeeze(pred))

imLab = np.asarray(torch.squeeze(label))

# Create empty numpy arrays

pixel_accuracy = np.empty(imLab.shape[0])

pixel_correct = np.empty(imLab.shape[0])

pixel_labeled = np.empty(imLab.shape[0])

# Compute pixel accuracy for each pair of images in the batch

for i in range(imLab.shape[0]):

pixel_accuracy[i], pixel_correct[i], pixel_labeled[i] = pixelAccuracy(imPred[i], imLab[i])

# Compute the final accuracy for the batch

acc = 100.0 * np.sum(pixel_correct) / (np.spacing(1) + np.sum(pixel_labeled))

return acc

开发者ID:vpulab,项目名称:Semantic-Aware-Scene-Recognition,代码行数:26,

示例3: semanticIoU

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import spacing [as 别名]

def semanticIoU(pred, label):

"""

Computes the mean Intersection over Union for all the classes between two mini-batch tensors of semantic

segmentation

:param pred: Tensor of predictions

:param label: Tensor of ground-truth

:return: Mean semantic intersection over Union for all the classes

"""

imPred = np.asarray(torch.squeeze(pred))

imLab = np.asarray(torch.squeeze(label))

area_intersection = []

area_union = []

for i in range(imLab.shape[0]):

intersection, union = intersectionAndUnion(imPred[i], imLab[i])

area_intersection.append(intersection)

area_union.append(union)

IoU = 1.0 * np.sum(area_intersection, axis=0) / np.sum(np.spacing(1)+area_union, axis=0)

return np.mean(IoU)

开发者ID:vpulab,项目名称:Semantic-Aware-Scene-Recognition,代码行数:24,

示例4: oks_iou

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import spacing [as 别名]

def oks_iou(g, d, a_g, a_d, sigmas=None, in_vis_thre=None):

if not isinstance(sigmas, np.ndarray):

sigmas = np.array([.26, .25, .25, .35, .35, .79, .79, .72, .72, .62, .62, 1.07, 1.07, .87, .87, .89, .89]) / 10.0

vars = (sigmas * 2) ** 2

xg = g[0::3]

yg = g[1::3]

vg = g[2::3]

ious = np.zeros((d.shape[0]))

for n_d in range(0, d.shape[0]):

xd = d[n_d, 0::3]

yd = d[n_d, 1::3]

vd = d[n_d, 2::3]

dx = xd - xg

dy = yd - yg

e = (dx ** 2 + dy ** 2) / vars / ((a_g + a_d[n_d]) / 2 + np.spacing(1)) / 2

if in_vis_thre is not None:

ind = list(vg > in_vis_thre) and list(vd > in_vis_thre)

e = e[ind]

ious[n_d] = np.sum(np.exp(-e)) / e.shape[0] if e.shape[0] != 0 else 0.0

return ious

开发者ID:facebookresearch,项目名称:PoseWarper,代码行数:22,

示例5: test_spacing_nextafter

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import spacing [as 别名]

def test_spacing_nextafter(self):

"""Test np.spacing and np.nextafter"""

# All non-negative finite #'s

a = np.arange(0x7c00, dtype=uint16)

hinf = np.arra

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值