Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tensorlayer/layers/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ElementwiseLayer(Layer):
combine_fn : a TensorFlow element-wise combine function
e.g. AND is ``tf.minimum`` ; OR is ``tf.maximum`` ; ADD is ``tf.add`` ; MUL is ``tf.multiply`` and so on.
See `TensorFlow Math API <https://www.tensorflow.org/versions/master/api_docs/python/math_ops.html#math>`__ .
act : activation function
The activation function of this layer.
name : str
A unique layer name.

Expand All @@ -102,19 +104,21 @@ def __init__(
self,
layers,
combine_fn=tf.minimum,
act=None,
name='elementwise_layer',
):
Layer.__init__(self, name=name)

logging.info("ElementwiseLayer %s: size:%s fn:%s" % (self.name, layers[0].outputs.get_shape(), combine_fn.__name__))

self.outputs = layers[0].outputs
# logging.info(self.outputs._shape, type(self.outputs._shape))

for l in layers[1:]:
if str(self.outputs.get_shape()) != str(l.outputs.get_shape()):
raise Exception("Hint: the input shapes should be the same. %s != %s" % (self.outputs.get_shape(), str(l.outputs.get_shape())))
self.outputs = combine_fn(self.outputs, l.outputs, name=name)

if act:
self.outputs = act(self.outputs)

self.all_layers = list(layers[0].all_layers)
self.all_params = list(layers[0].all_params)
self.all_drop = dict(layers[0].all_drop)
Expand Down