I’m trying to build a model for training data in python using TensorFlow, but it’s failing to build. Does anyone see any problems?
I’ve tried this so far:
def create_model(num_words, embedding_dim, lstm1_dim, lstm2_dim, num_categories):
tf.random.set_seed(200)
model = Sequential([layers.Dense(num_categories, activation='softmax'), layers.Embedding(num_words, embedding_dim),
layers.Bidirectional(layers.LSTM(lstm1_dim, return_sequences=True)), layers.Bidirectional(layers.LSTM(lstm2_dim))])
model.compile(loss='sparse_categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
return model
model = create_model(NUM_WORDS, EMBEDDING_DIM, 32, 16, 5)
print(model)
Whenever I print(model)
it says <Sequential name=sequential, built=False>.
New contributor
Awais Sandhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.