What does output_dim in Keras Dense mean?

I am a newbie in Deep Learning.By studding this article link .

I cannot understand what does the output_dim=128 and output_dim=1 mean???

I would expect as output in final Dense the number of classes=2(Cat/Dog).

Besides from where is the 128???

Upvotes: 1

Views: 3924

Answers (1)

Siong Thye Goh
Siong Thye Goh

Reputation: 3586

Output_dim is the dimension of the dense embedding.

The choice of 128 in

classifier.add(Dense(output_dim = 128, activation = 'relu'))

is quite arbitrary , it just indicate the size of fully connected layer that you prefer. You can change it to another number.

The 1 in

classifier.add(Dense(output_dim = 1, activation = 'sigmoid'))

is due to for a binary classification problem, we just require a probability to distinguish the 2 groups. If the probability is at least 0.5, we classify it as a dog, if it is less than 0.5, we classify it as a cat.

If you prefer, you can also set activation function to be softmax and output_dim to be 2 as the last layer though that would not improve the performance.

Upvotes: 2

Related Questions