Lesson 3 of 8Article18 min
Neural Networks Introduction
Neural networks are layers of weighted sums + non-linear activations. During training, the model adjusts weights to reduce prediction error using gradient descent and backpropagation.
How a neural network learns
Neural networks are layers of weighted sums + non-linear activations. During training, the model adjusts weights to reduce prediction error using gradient descent and backpropagation.
- Input layer -> hidden layers -> output layer.
- Loss function measures how wrong predictions are.
- Optimizer updates parameters iteratively.
Minimal dense network
Binary classifier in Keras
from tensorflow import keras
model = keras.Sequential([
keras.layers.Dense(32, activation="relu", input_shape=(20,)),
keras.layers.Dense(16, activation="relu"),
keras.layers.Dense(1, activation="sigmoid"),
])
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
model.fit(X_train, y_train, epochs=10, batch_size=32)