0
0
TensorFlowml~5 mins

Flatten and Dense layers in TensorFlow - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does a Flatten layer do in a neural network?
A Flatten layer takes a multi-dimensional input (like an image) and turns it into a single long list of numbers. This helps connect image data to layers that expect flat input.
Click to reveal answer
beginner
What is the purpose of a Dense layer in a neural network?
A Dense layer connects every input to every output neuron with weights. It helps the network learn patterns by combining inputs in different ways.
Click to reveal answer
beginner
Why do we often use a Flatten layer before a Dense layer?
Because Dense layers expect flat input, we use Flatten to convert multi-dimensional data (like images) into a flat list so the Dense layer can process it.
Click to reveal answer
beginner
In TensorFlow, how do you add a Flatten layer to a model?
You add it like this: tf.keras.layers.Flatten(). It will reshape the input to a flat vector automatically.
Click to reveal answer
intermediate
What activation function is commonly used in Dense layers for classification?
The 'softmax' activation is often used in the last Dense layer for multi-class classification to output probabilities.
Click to reveal answer
What shape does a Flatten layer output if the input shape is (28, 28, 1)?
A(28, 28, 1)
B(28, 28)
C(784,)
D(1, 784)
Which layer type connects every input neuron to every output neuron?
ADense
BPooling
CConvolutional
DFlatten
Why is Flatten needed before Dense layers when working with images?
ATo convert multi-dimensional data into a flat vector
BTo reduce the number of neurons
CTo increase image size
DTo apply activation functions
Which activation function is commonly used in the last Dense layer for multi-class classification?
ASigmoid
BSoftmax
CReLU
DTanh
In TensorFlow, how do you add a Dense layer with 10 neurons and ReLU activation?
Atf.keras.layers.Dense(activation='relu')
Btf.keras.layers.Flatten(10, activation='relu')
Ctf.keras.layers.Dense(10)
Dtf.keras.layers.Dense(10, activation='relu')
Explain in your own words why we use a Flatten layer before Dense layers in image classification models.
Think about how images are shaped and what Dense layers expect.
You got /3 concepts.
    Describe the role of Dense layers in a neural network and how they learn from data.
    Consider how neurons communicate and learn connections.
    You got /3 concepts.