当前位置: 首页>>代码示例>>Python>>正文


Python functional.prelu方法代码示例

本文整理汇总了Python中torch.nn.functional.prelu方法的典型用法代码示例。如果您正苦于以下问题:Python functional.prelu方法的具体用法?Python functional.prelu怎么用?Python functional.prelu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torch.nn.functional的用法示例。


在下文中一共展示了functional.prelu方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _relu

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import prelu [as 别名]
def _relu(raw, input, inplace=False):
    # for threshold or prelu
    x = raw(input, False)
    name = log.add_layer(name='relu')
    log.add_blobs([x], name='relu_blob')
    layer = caffe_net.Layer_param(name=name, type='ReLU',
                                  bottom=[log.blobs(input)], top=[log.blobs(x)])
    log.cnet.add_layer(layer)
    return x 
开发者ID:xxradon,项目名称:PytorchToCaffe,代码行数:11,代码来源:pytorch_to_caffe.py

示例2: emit_PRelu

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import prelu [as 别名]
def emit_PRelu(self, IR_node):
        code = "{:<15} = F.prelu({}, torch.from_numpy(__weights_dict['{}']['weights']))".format(
            IR_node.variable_name,
            self.parent_variable_name(IR_node, [0]),
            IR_node.name)
        
        if self.weight_loaded:
            self.weights_dict[IR_node.name]['weights'] = self.weights_dict[IR_node.name]['gamma']
        
        return code 
开发者ID:microsoft,项目名称:MMdnn,代码行数:12,代码来源:pytorch_emitter.py

示例3: _prelu

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import prelu [as 别名]
def _prelu(raw, input, weight):
    # for threshold or prelu
    x = raw(input, weight)
    bottom_blobs=[log.blobs(input)]
    name = log.add_layer(name='prelu')
    log.add_blobs([x], name='prelu_blob')
    layer = caffe_net.Layer_param(name=name, type='PReLU',
                                  bottom=bottom_blobs, top=[log.blobs(x)])
    if weight.size()[0]==1:
        layer.param.prelu_param.channel_shared=True
        layer.add_data(weight.cpu().data.numpy()[0])
    else:
        layer.add_data(weight.cpu().data.numpy())
    log.cnet.add_layer(layer)
    return x 
开发者ID:xxradon,项目名称:PytorchToCaffe,代码行数:17,代码来源:pytorch_to_caffe.py

示例4: _prelu

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import prelu [as 别名]
def _prelu(raw, input, weight):
    # for threshold or prelu
    x = raw(input, weight)
    bottom_blobs = [log.blobs(input)]
    name = log.add_layer(name='prelu')
    log.add_blobs([x], name='prelu_blob')
    layer = caffe_net.Layer_param(name=name, type='PReLU',
                                  bottom=bottom_blobs, top=[log.blobs(x)])
    if weight.size()[0] == 1:
        layer.param.prelu_param.channel_shared = True
        layer.add_data(weight.cpu().data.numpy()[0])
    else:
        layer.add_data(weight.cpu().data.numpy())
    log.cnet.add_layer(layer)
    return x 
开发者ID:JDAI-CV,项目名称:fast-reid,代码行数:17,代码来源:pytorch_to_caffe.py

示例5: test_prelu

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import prelu [as 别名]
def test_prelu(self):
        inp = torch.randn(1, 3, 32, 32, device='cuda', dtype=self.dtype)
        weight = torch.randn(1, device='cuda', dtype=self.dtype)
        output = F.prelu(inp, weight) 
开发者ID:NVIDIA,项目名称:apex,代码行数:6,代码来源:test_pyprof_nvtx.py

示例6: __init__

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import prelu [as 别名]
def __init__(self, num_params=3):
        super(LayerPReLUTest, self).__init__()
        self.num_params = num_params
        self.prelu = nn.PReLU(num_params) 
开发者ID:nerox8664,项目名称:onnx2keras,代码行数:6,代码来源:prelu.py

示例7: forward

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import prelu [as 别名]
def forward(self, x):
        x = self.prelu(x)
        return x 
开发者ID:nerox8664,项目名称:onnx2keras,代码行数:5,代码来源:prelu.py


注:本文中的torch.nn.functional.prelu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。