本文整理汇总了Python中torch.nn.modules.module.Module方法的典型用法代码示例。如果您正苦于以下问题:Python module.Module方法的具体用法?Python module.Module怎么用?Python module.Module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torch.nn.modules.module
的用法示例。
在下文中一共展示了module.Module方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: forward
# 需要导入模块: from torch.nn.modules import module [as 别名]
# 或者: from torch.nn.modules.module import Module [as 别名]
def forward(self, input):
# if not self.aux_loss:
return self.f(input)
# else:
# identity = torch.from_numpy(np.array([[1,0,0], [0,1,0]], dtype=np.float32))
# batch_identity = torch.zeros([input.size(0), 2,3])
# for i in range(input.size(0)):
# batch_identity[i] = identity
# batch_identity = Variable(batch_identity)
# loss = torch.mul(input - batch_identity, input - batch_identity)
# loss = torch.sum(loss,1)
# loss = torch.sum(loss,2)
# return self.f(input), loss.view(-1,1)
# class CylinderGridGen(Module):
# def __init__(self, height, width, lr = 1, aux_loss = False):
# super(CylinderGridGen, self).__init__()
# self.height, self.width = height, width
# self.aux_loss = aux_loss
# self.f = CylinderGridGenFunction(self.height, self.width, lr=lr)
# self.lr = lr
# def forward(self, input):
# if not self.aux_loss:
# return self.f(input)
# else:
# return self.f(input), torch.mul(input, input).view(-1,1)
示例2: forward
# 需要导入模块: from torch.nn.modules import module [as 别名]
# 或者: from torch.nn.modules.module import Module [as 别名]
def forward(self, input1, input2):
return minDepthFlowProjectionLayer.apply(input1, input2,self.requires_grad)
# class FlowFillholeModule(Module):
# def __init__(self,hole_value = -10000.0):
# super(FlowFillholeModule, self).__init__()
# self.f = FlowFillholeLayer()
#
# def forward(self, input1):
# return self.f(input1)
#we actually dont need to write the backward code for a module, since we have
示例3: forward
# 需要导入模块: from torch.nn.modules import module [as 别名]
# 或者: from torch.nn.modules.module import Module [as 别名]
def forward(self, input1, input2):
return DepthFlowProjectionLayer.apply(input1, input2,self.requires_grad)
# class FlowFillholeModule(Module):
# def __init__(self,hole_value = -10000.0):
# super(FlowFillholeModule, self).__init__()
# self.f = FlowFillholeLayer()
#
# def forward(self, input1):
# return self.f(input1)
#we actually dont need to write the backward code for a module, since we have