Keras Interview Questions (2026)

Practice 45 Keras interview questions on Keras 3, Sequential, Functional API, subclassing, layers, compile, fit, callbacks, saving, and transfer learning.

45 questions with answers

What Is Keras?

Key Takeaways

  • Keras is a high-level deep learning API used to build, train, evaluate, save, and deploy neural network models.
  • Keras 3 supports multiple backends, including TensorFlow, JAX, and PyTorch, while keeping one model-building API.
  • Interviews test Sequential, Functional API, subclassed models, compile, fit, callbacks, metrics, saving, and transfer learning.
  • Strong answers explain when simple APIs are enough and when custom training or subclassing is justified.

Keras is a high-level API for deep learning models. It gives candidates a clean way to define layers, connect inputs and outputs, train with compile and fit, track metrics, save models, and reuse pretrained networks. In interviews, Keras questions test model API choice, tensor shapes, callbacks, training control, serialization, and whether you can keep model code readable without hiding important decisions.

45Questions with direct answers
3Groups: Keras basics, model tasks, senior scenarios
7+Code, diagrams, tables, videos, and quiz
45-90 minTypical Keras interview round length

Watch: Keras 3: Deep Learning made easy

Video: Keras 3: Deep Learning made easy (Keras contributor talk, YouTube)

Test yourself and earn a certificate

6 quick questions. Score 70%+ to download your Keras certificate.

Jump to quiz

All Questions on This Page

45 questions
Keras Advanced Scenarios
  1. 31. Accuracy is 98 percent but the model misses fraud. What is wrong?
  2. 32. A saved Keras model fails to load in production. What do you check?
  3. 33. Loss does not improve. What do you inspect?
  4. 34. Training returns NaN loss. What do you do first?
  5. 35. A candidate subclasses every Keras model. What is your concern?
  6. 36. Fine-tuning makes validation worse quickly. What happened?
  7. 37. EarlyStopping stops before the model stabilizes. What do you change?
  8. 38. A multiclass model uses sigmoid with categorical cross-entropy. What do you question?
  9. 39. model.summary shows too many parameters. What is the risk?
  10. 40. Notebook metrics are good, but live predictions are poor. What do you inspect?
  11. 41. A custom layer works in eager mode but fails after saving. Why?
  12. 42. Validation scores are suspiciously high. What do you suspect?
  13. 43. A Keras 3 model must run on another backend. What do you verify?
  14. 44. GPU is idle during fit. What might be wrong?
  15. 45. What do you ask before approving Keras training code?

Keras Fundamentals

Foundational15 questions

Start here. These are the definitions and first-principle checks that open most rounds.

Q1. What changed with Keras 3?

Keras 3 is a multi-backend version of Keras that can run on TensorFlow, JAX, and PyTorch backends.

The interview point is API portability, not that every backend detail becomes identical.

Keras 3 changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Watch a deeper explanation

Video: Keras 3: Deep Learning made easy (Keras contributor talk, YouTube)

Q2. When would you use a Sequential model?

Use Sequential when the model is a simple stack with one input and one output.

It is readable but limited for branches, shared layers, or multiple outputs.

Sequential model changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

python
model = keras.Sequential([
    layers.Input(shape=(20,)),
    layers.Dense(64, activation='relu'),
    layers.Dense(1, activation='sigmoid')
])

Q3. Why use the Functional API?

The Functional API connects inputs and outputs as a graph, so it fits multi-input, multi-output, and shared-layer models.

It is the best default for non-linear model topologies.

Functional API changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q4. When is subclassing useful?

Subclassing is useful when the forward pass or layer behavior needs Python control that graph-style APIs do not express well.

It gives control but can make saving and inspection harder.

Subclassed model changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Answer partWhat to sayEvidence to mention
DefinitionSubclassed model in one direct sentence.Official docs or course material
Use caseThe work where it changes a decision.Dataset, model, query, dashboard, or pipeline
RiskWhat breaks when it is misunderstood.Metric, log, test result, or review note

Q5. What is a Keras layer?

A layer transforms input tensors into output tensors, often with trainable weights.

Dense, Conv2D, Dropout, BatchNormalization, and Embedding are common layers.

Layer changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Watch a deeper explanation

Video: TensorFlow beginner tutorial: build a neural net (TensorFlow, YouTube)

Q6. What does model.compile configure?

compile sets the optimizer, loss, metrics, and training behavior used by fit.

These choices must match target type and output activation.

Model compile changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q7. What does model.fit do?

fit trains a compiled model over batches of data for one or more epochs.

It can accept arrays, datasets, generators, validation data, and callbacks.

model.fit changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q8. How do you choose a Keras loss?

Choose the loss by task: binary cross-entropy for binary classification, categorical variants for multiclass, and MAE or MSE for regression.

Output activation and label encoding must agree.

Loss function changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q9. What does an optimizer do?

An optimizer updates trainable weights using gradients from the loss.

Adam is common, but optimizer choice and learning rate still need validation.

Optimizer changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q10. What is a Keras callback?

A callback runs logic during training, such as saving checkpoints, stopping early, logging metrics, or changing learning rate.

Callbacks keep training control out of the model architecture.

Callback changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q11. Why use ModelCheckpoint?

ModelCheckpoint saves model weights or full artifacts during training, often only when validation metrics improve.

It protects long training runs and keeps the best version.

ModelCheckpoint changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q12. What does EarlyStopping do?

EarlyStopping stops training when a monitored metric stops improving for a set patience.

It helps reduce overfitting and wasted training time.

EarlyStopping changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q13. What is transfer learning in Keras?

Transfer learning starts from a pretrained model and adapts it to a new task.

Usually you train a new head first, then fine-tune selected base layers.

Transfer learning changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Watch a deeper explanation

Video: TensorFlow 2.0 complete course (freeCodeCamp.org, YouTube)

Q14. How do you save and load Keras models?

Keras can save full models, weights, and configuration so they can be loaded for training or inference.

Custom layers or losses need proper serialization support.

Saving and loading changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q15. When would you write a custom layer?

Write a custom layer when repeated model logic has trainable weights or special tensor operations not covered by built-in layers.

Implement build, call, and serialization methods when needed.

Custom layer changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Back to question list

Keras Practical Interview Questions

Intermediate15 questions

These questions test whether you can apply the topic to real data, real code, and messy constraints.

Q16. Build a Keras binary classifier.

Define input shape, add hidden layers, use a sigmoid output, compile with binary cross-entropy, track a relevant metric, and fit with validation data.

If classes are imbalanced, mention precision, recall, PR AUC, class weights, or threshold tuning.

Q17. How would you build a model with two inputs?

Use the Functional API, create two Input tensors, process each branch, concatenate features, and connect the output.

Sequential is the wrong API for this shape.

functional model changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q18. Which callbacks would you use for a real training run?

Use ModelCheckpoint, EarlyStopping, TensorBoard, and learning-rate scheduling when the run needs those controls.

Do not add callbacks by habit. The job each one does.

train with callbacks changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q19. How do you debug Keras shape errors?

Check model.summary, input shape, batch dimension, layer output shapes, flattening, and label shape.

The expected shape at every boundary.

debug shape mismatch changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q20. A Keras model overfits. What do you change?

Use validation curves, dropout, regularization, augmentation, early stopping, smaller model size, or more data.

Pick changes based on evidence, not a checklist.

fix overfitting changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q21. How do you handle imbalanced classes?

Use class weights, sampling, threshold tuning, and metrics such as precision, recall, F1, or PR AUC.

Accuracy alone can look good while the model misses rare positives.

handle class imbalance changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q22. How do you fine-tune a pretrained Keras model?

Freeze the base, train the new head, unfreeze selected layers, lower the learning rate, and monitor validation metrics.

Unfreezing too much too early can destroy useful pretrained features.

fine-tune pretrained model changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q23. How do you save a model with custom layers?

Register or serialize custom objects, save the model artifact, and test loading it in a clean process.

A model is not saved safely until reload works.

save custom model changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q24. When would you write a custom metric?

Write a custom metric when built-in metrics do not match the business error or evaluation rule.

Keep training loss and reporting metric separate when needed.

custom metric changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q25. When do you skip model.fit?

Skip fit when the training step has unusual losses, multiple optimizers, special updates, or research logic.

The trade-off is more control and more code to test.

custom training loop changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Watch a deeper explanation

Video: Build a neural network with TensorFlow, Keras, and Python (TensorFlow tutorial, YouTube)

Q26. How do you tune learning rate?

a reasonable default, watch loss curves, try schedules, and reduce when validation stops improving comes first.

Too high can cause NaN or unstable loss. Too low can stall learning.

learning rate issue changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q27. Where should preprocessing live?

Use Keras preprocessing layers or a versioned input pipeline so training and inference apply the same transformations.

Mismatched preprocessing causes serving bugs.

input preprocessing changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q28. How do you train a multi-output Keras model?

Use the Functional API, name outputs, assign losses and loss weights, and track metrics per output.

Loss weighting decides what the model optimizes.

multi-output model changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q29. How do you inspect a Keras model?

Use model.summary, layer names, output shapes, trainable parameter counts, history metrics, and saved artifacts.

Inspection catches many design mistakes before training.

model inspection changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q30. How do you discuss Keras backend choice?

Explain which backend the team uses, what libraries it needs, and whether portability matters for the project.

Do not promise backend switching without testing custom code.

backend choice changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Back to question list

Keras Advanced Scenarios

Advanced15 questions

Advanced rounds test trade-offs, failure modes, and whether the decision can hold up under production pressure.

Q31. Accuracy is 98 percent but the model misses fraud. What is wrong?

The dataset is likely imbalanced, so accuracy is the wrong primary metric.

Use precision, recall, PR AUC, cost-based metrics, and threshold analysis.

metric looks good changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q32. A saved Keras model fails to load in production. What do you check?

Check Keras version, backend, custom objects, serialization methods, input signature, and artifact path.

Always test reload outside the notebook.

model will not load changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q33. Loss does not improve. What do you inspect?

Check labels, loss, output activation, learning rate, data scaling, trainable layers, and optimizer setup.

A frozen model head or wrong label encoding is common.

training stuck changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q34. Training returns NaN loss. What do you do first?

Check learning rate, input values, labels, normalization, invalid operations, and exploding gradients.

Run one tiny batch and inspect tensors.

NaN loss changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q35. A candidate subclasses every Keras model. What is your concern?

They may be hiding simple graph structure and making serialization harder.

Subclassing is useful, but it should have a reason.

subclassing overuse changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q36. Fine-tuning makes validation worse quickly. What happened?

The base may have been unfrozen too aggressively or trained with too high a learning rate.

Train the head first, then fine-tune carefully.

bad transfer learning changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q37. EarlyStopping stops before the model stabilizes. What do you change?

Tune patience, monitored metric, min_delta, validation quality, and learning-rate schedule.

The callback should fit the metric noise.

callback stops too soon changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q38. A multiclass model uses sigmoid with categorical cross-entropy. What do you question?

For single-label multiclass classification, softmax usually fits better.

Sigmoid fits independent multi-label outputs.

wrong output activation changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q39. model.summary shows too many parameters. What is the risk?

The model may overfit, train slowly, and cost more to serve.

Dense layers after flattening image features often cause this.

huge parameter count changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q40. Notebook metrics are good, but live predictions are poor. What do you inspect?

Check preprocessing, feature order, model version, input dtype, label mapping, and training-serving mismatch.

The model may be right and the serving path wrong.

serving skew changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q41. A custom layer works in eager mode but fails after saving. Why?

Serialization or config handling may be incomplete.

Custom layers need reload tests.

custom layer bug changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q42. Validation scores are suspiciously high. What do you suspect?

Data leakage, duplicate samples, bad split logic, or preprocessing fitted on all data.

Audit the split and data pipeline.

validation leakage changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q43. A Keras 3 model must run on another backend. What do you verify?

Check backend-supported ops, custom layers, random behavior, metrics, saving path, and numeric differences.

Portability is practical only after tests pass.

backend portability changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q44. GPU is idle during fit. What might be wrong?

The input pipeline may be slow due to decoding, augmentation, batching, or storage reads.

Profile data loading before changing the model.

slow input pipeline changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Q45. What do you ask before approving Keras training code?

Ask about API choice, shapes, labels, loss, metrics, callbacks, validation split, saving, reload tests, and serving contract.

Those questions catch most production failures.

senior review changes Keras decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.

Back to question list

Sequential vs Functional API vs Subclassing

Most Keras interviews ask which model API you would choose. The best technical choice uses the simplest API that still fits the model shape and training need.

APIUse whenStrengthWatch out
SequentialA straight stack of layersFast to read and writeNot enough for branched graphs
Functional APIMultiple inputs, outputs, or shared layersClear graph structureNeeds careful shape tracking
SubclassingCustom forward pass or unusual behaviorFull controlHarder to inspect and serialize
Custom training loopCustom loss or update logicFine controlMore code to test

Keras answer signals

Good answers choose the right level of control.

API choice
92 signal
Training setup
88 signal
Shape clarity
86 signal
Saving
80 signal
  • API choice: Sequential, Functional, subclassing
  • Training setup: compile, fit, metrics, callbacks
  • Shape clarity: inputs, outputs, batches
  • Saving: artifacts and custom objects

How to Prepare for a Keras Interview

Prepare by building a small classifier with all three Keras APIs, then explain why you would choose one for a real project.

  • Review layers, activations, losses, optimizers, metrics, callbacks, and model summaries.
  • Practice Sequential, Functional API, subclassed models, and a small custom training loop.
  • Know saving, loading, custom layers, transfer learning, and callbacks.
  • One debugging story about shape mismatch, overfitting, NaN loss, or a model that could not be loaded is useful.

Keras interview prep flow

1Shape
input and output tensors
2Build
choose model API
3Train
compile, fit, callbacks
4Check
metrics and errors
5Save
artifact and custom objects

Most rounds reward clear reasoning more than memorized phrasing.

How Strong Keras Answers Sound

A strong Keras answer starts with the model shape and training goal. Say why Sequential, Functional API, or subclassing fits the problem, which loss and metric match the target, how callbacks protect training, and how the model will be saved. production-ready answers mention custom layers, backend portability in Keras 3, input pipelines, model signatures, and training-serving consistency.

Keep simple models simple

A plain stack does not need subclassing. Over-custom code makes interviews harder to score.

Metric risk

Accuracy can hide class imbalance. Strong technical coverage picks metrics based on the business error.

Save with custom objects in mind

Custom layers, losses, and metrics need serialization planning.

Treat callbacks as controls

EarlyStopping, ModelCheckpoint, TensorBoard, and learning-rate callbacks solve different training problems.

Test Yourself: Keras Quiz

Ready to test your Keras knowledge?

6 questions, about 4 minutes. Score 70% or higher to earn a shareable certificate.

6 questions Instant feedback Free certificate on 70%+

Frequently  Asked  Questions

What do Keras interviews usually ask?

They ask about Keras 3, Sequential, Functional API, subclassing, layers, compile, fit, callbacks, metrics, saving, custom layers, and transfer learning.

Is Keras enough for deep learning interviews?

Keras is enough for model-building rounds, but you should also know tensors, gradients, losses, optimization, validation, and deployment basics.

What Keras project should I discuss?

Pick a model where you chose the API, handled shapes, used callbacks, tuned metrics, saved the model, and fixed a real training issue.

What separates experienced Keras candidates?

Experienced candidates explain API trade-offs, custom object serialization, transfer learning, metric risk, reload tests, and serving consistency. Complete coverage has one concrete example, one failure case, and one validation signal beyond the definition.

Practice Keras answers before ML interviews

Use this Keras bank for model-building answers, then practice Python and model debugging tasks with Hyring's AI Coding Interviewer.

See Hyring AI Coding Interviewer

Sources

Adithyan RKWritten by Adithyan RK
Surya N
Fact-checked by Surya N
Published on: 20 May 2026Last updated: 11 Jul 2026
Share: