Reputation: 703
Why are there exactly 128 nodes in the second layer of keras model for FASHION MNIST problem?
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(10, activation='softmax')
])
Upvotes: 2
Views: 1808
Reputation: 703
In this tutorial, we are just making a simple neural network so 128 nodes are enough and some neural network suggests if the number of neurons or nodes are in the power of 2 it is easy for computation purpose 128 is the power of 2 (2^7) as it is not too small or too large hence it is enough for a simple neural network.
But you can try any other numbers too, more formally, the number of nodes depends on data size you can give it any number but if you give a larger magnitude for larger data there is a chance of overfitting.
Overfitting: When a model gets trained with so much data, it starts learning from the noise and inaccurate data entries in our data set. Then the model does not categorize the data correctly, because of too much of details and noise.
Refer : https://www.geeksforgeeks.org/underfitting-and-overfitting-in-machine-learning/
Upvotes: 2
Reputation: 1079
Basically you can specify any number for it, only if the result(accuracy,latency,etc.)is good enough for you, and also your hardware can run it.
Upvotes: 2