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


Python torch.atan方法代碼示例

本文整理匯總了Python中torch.atan方法的典型用法代碼示例。如果您正苦於以下問題:Python torch.atan方法的具體用法?Python torch.atan怎麽用?Python torch.atan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在torch的用法示例。


在下文中一共展示了torch.atan方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: forward

# 需要導入模塊: import torch [as 別名]
# 或者: from torch import atan [as 別名]
def forward(self, input):
        self.batchgrid = torch.zeros(torch.Size([input.size(0)]) + self.grid.size() )
        #print(self.batchgrid.size())
        for i in range(input.size(0)):
            self.batchgrid[i,:,:,:] = self.grid
        self.batchgrid = Variable(self.batchgrid)

        #print(self.batchgrid.size())

        input_u = input.view(-1,1,1,1).repeat(1,self.height, self.width,1)
        #print(input_u.requires_grad, self.batchgrid)

        output0 = self.batchgrid[:,:,:,0:1]
        output1 = torch.atan(torch.tan(np.pi/2.0*(self.batchgrid[:,:,:,1:2] + self.batchgrid[:,:,:,2:] * input_u[:,:,:,:])))  /(np.pi/2)
        #print(output0.size(), output1.size())

        output = torch.cat([output0, output1], 3)
        return output 
開發者ID:guoruoqian,項目名稱:cascade-rcnn_Pytorch,代碼行數:20,代碼來源:gridgen.py

示例2: tobin

# 需要導入模塊: import torch [as 別名]
# 或者: from torch import atan [as 別名]
def tobin(self, target):
        indxneg = target.data[:,0,:,:] < 0
        eps = torch.zeros(target.data[:,0,:,:].size()).cuda()
        epsind = target.data[:,0,:,:] == 0
        eps[epsind] += 1e-5
        angle = torch.atan(target.data[:,1,:,:] / (target.data[:,0,:,:] + eps))
        angle[indxneg] += np.pi
        angle += np.pi / 2 # 0 to 2pi
        angle = torch.clamp(angle, 0, 2 * np.pi - 1e-3)
        radius = torch.sqrt(target.data[:,0,:,:] ** 2 + target.data[:,1,:,:] ** 2)
        radius = torch.clamp(radius, 0, self.fmax - 1e-3)
        quantized_angle = torch.floor(self.abins * angle / (2 * np.pi))
        if self.quantize_strategy == 'linear':
            quantized_radius = torch.floor(self.rbins * radius / self.fmax)
        elif self.quantize_strategy == 'quadratic':
            quantized_radius = torch.floor(self.rbins * torch.sqrt(radius / self.fmax))
        else:
            raise Exception("No such quantize strategy: {}".format(self.quantize_strategy))
        quantized_target = torch.autograd.Variable(torch.cat([torch.unsqueeze(quantized_angle, 1), torch.unsqueeze(quantized_radius, 1)], dim=1))
        return quantized_target.type(torch.cuda.LongTensor) 
開發者ID:XiaohangZhan,項目名稱:conditional-motion-propagation,代碼行數:22,代碼來源:losses.py

示例3: forward

# 需要導入模塊: import torch [as 別名]
# 或者: from torch import atan [as 別名]
def forward(self, input):
        self.batchgrid = torch.zeros(
            torch.Size([input.size(0)]) + self.grid.size())
        # print(self.batchgrid.size())
        for i in range(input.size(0)):
            self.batchgrid[i, :, :, :] = self.grid
        self.batchgrid = Variable(self.batchgrid)

        # print(self.batchgrid.size())

        input_u = input.view(-1, 1, 1, 1).repeat(1, self.height, self.width, 1)
        # print(input_u.requires_grad, self.batchgrid)

        output0 = self.batchgrid[:, :, :, 0:1]
        output1 = torch.atan(torch.tan(
            np.pi / 2.0 * (
                    self.batchgrid[:, :, :, 1:2] + self.batchgrid[:, :, :,
                                                   2:] * input_u[:, :, :,
                                                         :]))) / (
                          np.pi / 2)
        # print(output0.size(), output1.size())

        output = torch.cat([output0, output1], 3)
        return output 
開發者ID:ucbdrive,項目名稱:3d-vehicle-tracking,代碼行數:26,代碼來源:gridgen.py

示例4: forward

# 需要導入模塊: import torch [as 別名]
# 或者: from torch import atan [as 別名]
def forward(self, inputs, context=None):
        outputs = (1 / np.pi) * torch.atan(inputs) + 0.5
        logabsdet = utils.sum_except_batch(
            - np.log(np.pi) - torch.log(1 + inputs ** 2)
        )
        return outputs, logabsdet 
開發者ID:bayesiains,項目名稱:nsf,代碼行數:8,代碼來源:nonlinearities.py


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