By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
A neural network is a stack of perceptrons (tiny linear classifiers) linked by activation functions that let the model learn non‑linear patterns. During training the network adjusts its weights with back‑propagation, minimizing a loss function (e.g., cross‑entropy). In a data‑science workflow the NN replaces a hand‑crafted feature pipeline when the relationship between inputs and the target is too complex for linear models—think predicting churn from dozens of behavioural logs, classifying skin‑lesion images for early melanoma detection, or generating personalized product recommendations from click‑stream data.
z = w·x + b
a = φ(z)
w
x
b
φ
σ(z) = 1 / (1 + e^{-z})
ReLU(z) = max(0, z)
softmax_i(z) = e^{z_i} / Σ_j e^{z_j}
L = -[y·log(p) + (1‑y)·log(1‑p)]
y∈{0,1}
p = σ(z)
L = - Σ_{k=1}^K y_k·log(softmax_k(z))
y
∂L/∂w = (a - y)·x
∇_W L = δ·A^{T}
δ
δ^{(l)} = (W^{(l+1)})^{T} δ^{(l+1)} ⊙ φ'(z^{(l)})
W := W - α·∇_W L
W ∼ N(0, 2/fan_in)
N(0, 1/fan_in)
λ·||W||_2^2
df = pd.read_csv(...)
StandardScaler
MinMaxScaler
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, stratify=y)
python model = tf.keras.Sequential([ tf.keras.layers.Dense(128, activation='relu', input_shape=(n_features,)), tf.keras.layers.Dense(64, activation='relu'), tf.keras.layers.Dense(1, activation='sigmoid') # binary churn ]) model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=1e-3), loss='binary_crossentropy', metrics=['AUC'])
python es = tf.keras.callbacks.EarlyStopping(patience=5, restore_best_weights=True) history = model.fit(X_train, y_train, validation_data=(X_val, y_val), epochs=100, batch_size=256, callbacks=[es])
tf.keras.layers.Dropout(0.3)
tf.keras.optimizers.schedules.ExponentialDecay
model.fit(..., shuffle=True)
tf.data.Dataset.shuffle
1e-4
(p‑y)
Scenario: Your churn model’s validation loss stops decreasing after epoch 3, but training loss keeps falling. Answer: Apply early stopping and increase regularization (e.g., add dropout or L2). Why? The gap signals over‑fitting; early stopping prevents further memorisation.
Scenario: You need a multi‑class classifier for 10 disease categories and want calibrated probabilities. Answer: Use a softmax output layer with categorical cross‑entropy loss. Why? Softmax guarantees a proper probability simplex; cross‑entropy directly optimises likelihood.
Scenario: After adding a new hidden layer, training becomes extremely slow and loss stays near 0.5. Answer: Switch the hidden activation to ReLU and re‑initialize weights with He initialization. Why? Sigmoid saturates; ReLU + He keep gradients alive.
a = φ(w·x + b)
σ'(z) = σ(z)·(1‑σ(z))
ReLU'(z) = 1 if z>0 else 0
δ^{(l)} = (W^{(l+1)})ᵀ δ^{(l+1)} ⊙ φ'(z^{(l)})
W ← W – α·∇_W L
p_k = e^{z_k} / Σ_j e^{z_j}
Var(W) = 2 / fan_in
1/(1‑p)
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.