Skip to content

Keras.js Error: [Model] Model configuration does not contain any layers.  #134

@hmhwe

Description

@hmhwe

I tried to run keras model on a browser using keras.js , but I got the following error while loading it

Error: [Model] Model configuration does not contain any layer
The kera model is

from keras.models import Sequential
from keras.layers import Dense, LSTM, InputLayer, Bidirectional, TimeDistributed, Embedding, Activation
from keras.optimizers import Adam
model = Sequential()
model.add(InputLayer(input_shape=(MAX_LENGTH, )))
model.add(Embedding(len(word2index), 128))
model.add(Bidirectional(LSTM(256, return_sequences=True)))
model.add(TimeDistributed(Dense(len(tag2index))))
model.add(Activation('softmax'))
 
model.compile(loss='categorical_crossentropy',
              optimizer=Adam(0.001),
              metrics=['accuracy', ignore_class_accuracy(0)])
 
model.summary()

Then I have converted with encoder.py as

python encoder.py model.hdf5
And load it with keras.js as

cconst model= new KerasJS.Model({
        filepath: {
          model: 'model.json',
          weights: 'model_weights.buf',
          metadata: 'model_metadata.json'
        },

          gpu: false
        })

I have tried with keras version 2.2.4 , 2.1.4, 2.2.2, 2.1.5 and 2.1.4 .

Any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions