當前位置: 首頁>>代碼示例>>Python>>正文


Python module.Module方法代碼示例

本文整理匯總了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) 
開發者ID:roytseng-tw,項目名稱:Detectron.pytorch,代碼行數:31,代碼來源:gridgen.py

示例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 
開發者ID:baowenbo,項目名稱:DAIN,代碼行數:14,代碼來源:minDepthFlowProjectionModule.py

示例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 
開發者ID:baowenbo,項目名稱:DAIN,代碼行數:14,代碼來源:DepthFlowProjectionModule.py


注:本文中的torch.nn.modules.module.Module方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。