You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i then run model = await tf.loadLayersModel('js_model/model.json'); which causes the error "Initialization error: An InputLayer should be passed either abatchInputShapeor aninputShape."
the model i am runing is a stupidly simple lstm all native tensorflow. runing conversion from both h5 and keras seems to work at first but then it gives that crush.
the full model code
vocab_size=len(vectorizer) # Number of unique words in your vocabularyembedding_dim=340seq_length=340# Max sequence lengthnum_classes=1inputs=Input(shape=(seq_length,))
embedding=Embedding(input_dim=vocab_size, output_dim=embedding_dim, input_length=seq_length)(inputs)
cnn=Conv1D(filters=128, kernel_size=5, activation='relu', padding='same')(embedding)
cnn=BatchNormalization()(cnn)
cnn=MaxPooling1D(pool_size=4)(cnn)
cnn=Conv1D(filters=256, kernel_size=3, activation='relu', padding='same')(cnn)
cnn=BatchNormalization()(cnn)
cnn=MaxPooling1D(pool_size=2)(cnn)
lstm=LSTM(128, return_sequences=True, dropout=0.3, recurrent_dropout=0.3)(cnn)
lstm=LSTM(64, return_sequences=False, dropout=0.3, recurrent_dropout=0.3)(lstm)
dense=Dense(256, activation='relu')(lstm)
dense=Dropout(0.5)(dense)
dense=Dense(128, activation='relu')(dense)
dense=Dropout(0.5)(dense)
dense=Dense(64, activation='relu')(dense)
outputs=Dense(num_classes, activation='sigmoid')(dense)
model=Model(inputs=inputs, outputs=outputs)
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
model.summary()
The text was updated successfully, but these errors were encountered:
This is a known issue with TFJS currently. Tfjs-converter does not support models created by Keras 3. When you try to load this model using model = await tf.loadLayersModel('js_model/model.json'), it will attempt to infer the input shape which is not present in the model.json file.
You can install Keras 2 (TensorFlow 2.15.0) to create your model and then use the tfjs-converter to convert the TensorFlow model to a TFJS model. Or alternatively, you can load your current model as a Graph Model instead of a Layer Model using const model = await tf.loadGraphModel(modelUrl);.
so i am on ubuntu 20 and i have this in my html file i am opening on firefox with the fillowing link https://cdn.jsdelivr.net/npm/@tensorflow/tfjs
i then run model = await tf.loadLayersModel('js_model/model.json'); which causes the error
"Initialization error: An InputLayer should be passed either a
batchInputShapeor an
inputShape."
the model i am runing is a stupidly simple lstm all native tensorflow. runing conversion from both h5 and keras seems to work at first but then it gives that crush.
the full model code
The text was updated successfully, but these errors were encountered: