1

I'm newbie in Neural Network. I'm going to do a text classification research using MLP model with keras. Input layer consisting of 900 nodes, 2 hidden layers, and 2 outputs.

The code I use is as follows:

model = Sequential()
model.add(Dense(units = 100, activation = 'sigmoid'))
model.add(Dense(units = 100, activation = 'sigmoid'))
model.add(Dense(units = 2, activation = 'sigmoid'))
opt = Adam (learning_rate=0.001)
model.compile(loss = 'binary_crossentropy', optimizer = opt, metrics = ['accuracy'])
print(model.summary())

But get error:

This model has not yet been built. Build the model first by calling `build()` or by calling the model on a batch of data.

How to fix that error? Thank you.

Andryan
  • 11
  • 2
  • 1
    To run `summary()` you need to define the shape of the input data which you didn't provide. – NotAName Jan 04 '23 at 06:13
  • How to define the shape of the input data? – Andryan Jan 04 '23 at 06:15
  • 1
    When you define Sequential model, the first layer should take an `input_shape` parameter. For example, `Dense(units = 100, activation = 'sigmoid', input_shape=(1, 1))` – NotAName Jan 04 '23 at 06:26

0 Answers0