Skip to content

Commit

Permalink
Reapply patches to legacy Merge layer (keras-team#5791)
Browse files Browse the repository at this point in the history
* Bug fix : Model.from_config (keras-team#5730)

* Add merge mode 'max' where it was missing (fixes keras-team#3486) (keras-team#5729)
  • Loading branch information
Yorwba authored and fchollet committed Mar 15, 2017
1 parent a8eb2e9 commit 7095aca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions keras/legacy/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def compute_mask(self, inputs, mask=None):

assert hasattr(mask, '__len__') and len(mask) == len(inputs)

if self.mode in ['sum', 'mul', 'ave']:
if self.mode in ['sum', 'mul', 'ave', 'max']:
masks = [K.expand_dims(m, 0) for m in mask if m is not None]
return K.all(K.concatenate(masks, axis=0), axis=0, keepdims=False)
elif self.mode == 'concat':
Expand Down Expand Up @@ -361,6 +361,7 @@ def get_config(self):

@classmethod
def from_config(cls, config):
config = config.copy()
mode_type = config.pop('mode_type')
if mode_type == 'function':
mode = globals()[config['mode']]
Expand Down Expand Up @@ -406,7 +407,7 @@ def merge(inputs, mode='sum', concat_axis=-1,
```
# Arguments
mode: String or lambda/function. If string, must be one
of: 'sum', 'mul', 'concat', 'ave', 'cos', 'dot'.
of: 'sum', 'mul', 'concat', 'ave', 'cos', 'dot', 'max'.
If lambda/function, it should take as input a list of tensors
and return a single tensor.
concat_axis: Integer, axis to use in mode `concat`.
Expand Down

0 comments on commit 7095aca

Please sign in to comment.