transcranial / keras-js

Run Keras models in the browser, with GPU support using WebGL
https://transcranial.github.io/keras-js
MIT License
4.96k stars 503 forks source link

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

Open hmhwe opened 5 years ago

hmhwe commented 5 years ago

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. 
avyabansal commented 4 years ago

2.0.6 version removed this error for me