You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Keras-users
I have a model built with the functional API which is composed of other models. This breaks some tools which analyze keras graphs. Is there a function in keras which allows me to "flatten" these nested models so that when I do a model.layers, the list does not contain any keras.models?
Isaac
fabia...@googlemail.com
unread,
Jan 27, 2017, 5:23:35 AM1/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Keras-users
Hi Isaac,
I just had the same problem. Here is my solution for only one level of nesting. For multiple levels of nesting you could use recursion of course.
layers_flat = []
for layer in model_nested.layers:
try:
layers_flat.extend(layer.layers)
except AttributeError:
layers_flat.append(layer)
model_flat = Sequential(layers_flat)
Fabian
Isaac Gerg
unread,
Jan 27, 2017, 11:13:20 AM1/27/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message