3 from __future__
import absolute_import
4 from __future__
import division
5 from __future__
import print_function
6 from __future__
import unicode_literals
11 def prelu(model, blob_in, blob_out, num_channels=1, slope_init=None,
15 slope_init
if slope_init
else (
'ConstantFill', {
'value': 0.25}))
17 slope = model.param_init_net.__getattr__(slope_init[0])(
24 slope = core.ScopedBlobReference(
25 blob_out +
'_slope', model.param_init_net)
27 model.AddParameter(slope)
29 return model.net.PRelu([blob_in, slope], [blob_out])
32 def relu(model, blob_in, blob_out, use_cudnn=False, order="NCHW", **kwargs):
35 kwargs[
'engine'] =
'CUDNN' 36 return model.net.Relu(blob_in, blob_out, order=order, **kwargs)
39 def tanh(model, blob_in, blob_out, use_cudnn=False, order="NCHW", **kwargs):
42 kwargs[
'engine'] =
'CUDNN' 43 return model.net.Tanh(blob_in, blob_out, order=order, **kwargs)