本文整理汇总了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
示例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
示例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
示例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
示例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)
示例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)
示例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