本文整理汇总了Python中torch.autograd.Variable.min方法的典型用法代码示例。如果您正苦于以下问题:Python Variable.min方法的具体用法?Python Variable.min怎么用?Python Variable.min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torch.autograd.Variable
的用法示例。
在下文中一共展示了Variable.min方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SkeletonsMaps
# 需要导入模块: from torch.autograd import Variable [as 别名]
# 或者: from torch.autograd.Variable import min [as 别名]
s_map = SkeletonsMaps()
worm_roi_t = worm_roi_t.cuda()
s_seed = s_seed.cuda()
skel_width = skel_width.cuda()
model = model.cuda()
s_map = s_map.cuda()
worm_roi_t = Variable(worm_roi_t)
s_seed = Variable(s_seed)
skel_width = Variable(skel_width)
#%%
maps_o = s_map(s_seed, skel_width)
mm = maps_o - worm_roi_t
#%%
bot = worm_roi_t.min()
top = worm_roi_t.max()
worm_roi_n = (worm_roi_t.squeeze() - bot)/(top-bot)
p_w = (maps_o*worm_roi_n) + 1.e-5
skel_map_inv = (-maps_o).add_(1)
worm_img_inv = (-worm_roi_n.squeeze()).add_(1)
p_bng = (skel_map_inv*worm_img_inv) + 1.e-5
#p_bng = torch.sqrt(p_bng)
#c_loss = F.binary_cross_entropy(p_w, p_bng)
c_loss = -(p_bng*torch.log(p_w) + p_w*torch.log(p_bng)).mean()
示例2: Exception
# 需要导入模块: from torch.autograd import Variable [as 别名]
# 或者: from torch.autograd.Variable import min [as 别名]
#test_battery(C_h_100, 'cifar100')
raise Exception('done')
batches = []
def denorm(inp):
return (inp+2.0)/4.0
for i, (train, target) in enumerate(train_loader):
print train.size()
train = Variable(train.cuda())
print train.min(), train.max()
batches.append(train)
if i > 0:
break
print len(batches)
interp = (batches[0] + batches[1])/2.0
h1 = C.compute_h2(batches[0])
h2 = C.compute_h2(batches[1])
print h1.size()