def custom_layer(incoming, custom_fn, **kwargs):
""" Custom Layer.
A custom layer that can apply any operations to the incoming Tensor or
list of `Tensor`. The custom function can be pass as a parameter along
with its parameters.
Arguments:
incoming : A `Tensor` or list of `Tensor`. Incoming tensor.
custom_fn : A custom `function`, to apply some ops on incoming tensor.
**kwargs: Some custom parameters that custom function might need.
"""
name = "CustomLayer"
if 'name' in kwargs:
name = kwargs['name']
with tf.name_scope(name):
inference = custom_fn(incoming, **kwargs)
return inference
评论列表
文章目录