Machine Learning · Chapter 31 of 40
Neural Networks Basics
A NEURAL NETWORK stacks layers of neurons. Each neuron computes `activation(w·x + b)`.
Deep networks learn hierarchical features and power state-of-the-art vision, speech and language systems.
Example 1 (python)
# Simple feed-forward net with Keras
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])Two dense layers.
Example 2 (python)
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(X_train, y_train, epochs=5)Compile, then fit.
Key points
- Layers of neurons compute w·x + b.
- Non-linear activations (ReLU, sigmoid).
- Trained with gradient descent + backprop.
- Deep = many layers.
💡 Note: For tabular data, tree-based models (XGBoost, LightGBM) often beat neural nets. Neural nets shine on images, audio and text.
