stared / keras-sequential-ascii

ASCII summary for simple sequential models in Keras
125 stars 17 forks source link

Error using lambda layers #3

Open Jbiloki opened 5 years ago

Jbiloki commented 5 years ago
           OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)

               Input   #####     72  300
          InputLayer     |   -------------------         0     0.0%
                       #####     72  300
               Dense   XXXXX -------------------     15050    92.0%
                       #####     72   50
          InputLayer     |   -------------------         0     0.0%
                       #####     72    3
         Concatenate   ????? -------------------         0     0.0%
                       #####     72   53
                LSTM   LLLLL -------------------      1180     7.0%
                tanh   #####           5
              Lambda   ????? -------------------         0     0.0%
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-222-96aac99b2755> in <module>()
----> 1 keras2ascii(lstm_model)

/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/keras_sequential_ascii/main.pyc in sequential_model_to_ascii_printout(model, sparser, simplify, header)
    123 
    124 def sequential_model_to_ascii_printout(model, sparser=False, simplify=True, header=True):
--> 125     print_layers(jsonize(model), sparser=sparser, simplify=simplify, header=header)

/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/keras_sequential_ascii/main.pyc in print_layers(jsonized_layers, sparser, simplify, header)
    118         print(data_template.format(
    119                 activation=each["activation"] if each["activation"] != "linear" else "",
--> 120                 shape=print_dim_tuple(each["output_shape"]),
    121                 # length=product(each["output_shape"])
    122         ))

/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/keras_sequential_ascii/main.pyc in print_dim_tuple(t)
     83         return " ".join(["{:4d}".format(x) for x in t])
     84     else:
---> 85         return  "{:9d}".format(t[0])
     86 
     87 def print_layers(jsonized_layers, sparser=False, simplify=False, header=True):

IndexError: tuple index out of range

For model:

x = Input(shape=(72,300))
aux_input = Input(shape=(72, 3))
probs = Input(shape=(1,))
dim_reduct = Dense(50)(x)
cat = concatenate([dim_reduct, aux_input])
encoded = LSTM(5)(cat)
#cat2 = concatenate([encoded, probs])
#output = Dense(1, activation='linear')(encoded)

output = Lambda(lambda x: K.sum(x, axis=1))(encoded)
stared commented 5 years ago

@Jbiloki Thanks for brining this up. Though, I no longer develop the project. (Mostly, as it is restricted to a small subset of network architectures.)

For wider inspirations, see: https://medium.com/inbrowserai/simple-diagrams-of-convoluted-neural-networks-39c097d2925b