Python torch.nn.modules.module.Module() Examples

The following are 11 code examples of torch.nn.modules.module.Module(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module torch.nn.modules.module , or try the search function .
Example #1
Source File: gridgen.py    From Detectron.pytorch with MIT License 5 votes vote down vote up
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) 
Example #2
Source File: gridgen.py    From FPN-Pytorch with MIT License 5 votes vote down vote up
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) 
Example #3
Source File: gridgen.py    From pcl.pytorch with MIT License 5 votes vote down vote up
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) 
Example #4
Source File: gridgen.py    From Detectron.pytorch with MIT License 5 votes vote down vote up
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) 
Example #5
Source File: gridgen.py    From PANet with MIT License 5 votes vote down vote up
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) 
Example #6
Source File: gridgen.py    From PMFNet with MIT License 5 votes vote down vote up
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) 
Example #7
Source File: gridgen.py    From Large-Scale-VRD.pytorch with MIT License 5 votes vote down vote up
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) 
Example #8
Source File: gridgen.py    From detectron-self-train with MIT License 5 votes vote down vote up
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) 
Example #9
Source File: gridgen.py    From DIoU-pytorch-detectron with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #10
Source File: minDepthFlowProjectionModule.py    From DAIN with MIT License 5 votes vote down vote up
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 
Example #11
Source File: DepthFlowProjectionModule.py    From DAIN with MIT License 5 votes vote down vote up
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