TensorFlow interview questions test TensorFlow 2's eager-first model, tf.function graphs and retracing, GradientTape, the Keras 3 model APIs and training loop, tf.data input pipelines, distribution strategies, and how models are saved and served. On November 17, 2026, PyPI listed TensorFlow 2.21.0 (March 6, 2026) as the latest stable release, with 2.22.0rc1 as a release candidate. TensorFlow's release notes say 2.16 made Keras 3 the default and removed tf.estimator, and 2.20 told users to migrate from tf.lite to LiteRT.
Below are 30 questions by level, five debugging scenarios and how ML interviews test this. Theory follow-ups are in deep learning interview questions, and the role-level view is in machine learning engineer interview questions.
TensorFlow interview questions: fundamentals (1–10)
- What is TensorFlow? Google's open-source machine learning platform: tensors, automatic differentiation and GPU and TPU support, with Keras as the high-level API,
tf.datafor input pipelines and TF Serving and LiteRT for deployment. - What is eager execution? The TensorFlow 2 default: operations run immediately and return concrete values, so you can debug with ordinary Python.
- tf.Tensor versus tf.Variable? Tensors are immutable values. Variables hold mutable state such as weights, change with
assign, and are tracked automatically for gradients when trainable. - What are the three Keras model APIs? Sequential for a linear stack of layers; Functional for graphs with multiple inputs or outputs and shared layers; subclassing
keras.Modelwith a customcall()for full control. - What do compile and fit do?
model.compile(optimizer="adam", loss=..., metrics=[...])configures training;model.fit(x, y, epochs=10, validation_data=..., callbacks=[...])runs it;evaluateandpredictfollow. - Sparse or categorical cross-entropy?
SparseCategoricalCrossentropyfor integer labels,CategoricalCrossentropyfor one-hot labels. Setfrom_logits=Truewhen the last layer has no softmax. - Which callbacks matter?
EarlyStopping(monitor="val_loss", patience=5, restore_best_weights=True),ModelCheckpoint,ReduceLROnPlateauandTensorBoard. - How do you reduce overfitting? More data or augmentation, dropout, L2 regularization, early stopping, a smaller model, and a validation split that reflects real data.
- What is Keras 3? A multi-backend Keras that runs on TensorFlow, JAX or PyTorch. It became the default in TensorFlow 2.16; to stay on Keras 2, the release notes say to install
tf-kerasand setTF_USE_LEGACY_KERAS=1. - How do you save a Keras model?
model.save("model.keras")writes the native Keras format, and the path must end in.keras; reload it withkeras.models.load_model.
Intermediate TensorFlow questions (11–20)
- How does GradientTape work?
with tf.GradientTape() as tape: loss = loss_fn(y, model(x, training=True)), thengrads = tape.gradient(loss, model.trainable_variables)andoptimizer.apply_gradients(zip(grads, model.trainable_variables)). - What does tf.function do? It traces a Python function into a graph that runs faster and can be exported. Python side effects such as
printrun only while tracing; usetf.printinside. - What causes retracing? New input shapes or dtypes, or new Python argument values, each create a new graph. Pass tensors instead of Python numbers, fix an
input_signature, or setreduce_retracing=True. - What is AutoGraph? The converter inside
tf.functionthat turns Pythonifandwhileon tensors into graph control flow such astf.condandtf.while_loop. - Build an efficient tf.data pipeline.
ds.map(parse, num_parallel_calls=tf.data.AUTOTUNE).cache().shuffle(10000).batch(64).prefetch(tf.data.AUTOTUNE): parse in parallel, cache after expensive work, shuffle before batching, prefetch last. - How big should the shuffle buffer be? Large enough to mix the data well; a buffer that holds the whole dataset gives a full shuffle if it fits in memory. A tiny buffer over sorted data barely shuffles.
- Why does the training argument matter? Dropout and batch normalization behave differently in training and inference. Pass
training=TrueorFalsein custom loops. In Keras, settingtrainable=Falseon a BatchNormalization layer also makes it run in inference mode, which matters when fine-tuning. - How do you do transfer learning? Load a pretrained base from
keras.applications, setbase.trainable = False, train a new head, then unfreeze the top layers and continue with a low learning rate. - How do you customize training but keep fit()? Override
train_stepin akeras.Modelsubclass, so callbacks, metrics and distribution still work with your own step logic. - How do you enable mixed precision?
keras.mixed_precision.set_global_policy("mixed_float16"), keeping the final layer in float32 for numeric stability;fitapplies loss scaling for you.
Experienced and senior TensorFlow questions (21–30)
- Which distribution strategies exist?
MirroredStrategy(several GPUs on one machine, synchronous),MultiWorkerMirroredStrategy,TPUStrategyandParameterServerStrategy. Build and compile the model insidestrategy.scope(). - How do you export for TF Serving? In Keras 3,
model.export("path", format="tf_saved_model")writes a SavedModel for TF Serving. Per keras.io,exportalso supportsonnx,openvino,litertandtorchformats. - What is happening with TensorFlow Lite? It is now LiteRT. The 2.20 release notes say
tf.litewill be removed from the TensorFlow Python package in a future release, andtf.lite.Interpreterwarns and points toai_edge_litert.interpreter. - How do you find a performance bottleneck? The TensorBoard profiler shows input-pipeline stalls and slow ops. Common fixes: a better
tf.datapipeline, larger batches, mixed precision and XLA viajit_compile=True. - Why does TensorFlow grab all GPU memory? By default it maps most GPU memory at startup.
tf.config.experimental.set_memory_growth(gpu, True)allocates on demand, which helps when processes share a GPU. - How do you write a custom layer? Subclass
keras.layers.Layer, create weights inbuild(input_shape)withadd_weight, compute incall, and implementget_configso the model can be saved and reloaded. - What are ragged and sparse tensors?
tf.RaggedTensorholds variable-length rows such as tokenized sentences;tf.sparse.SparseTensorstores mostly-zero data efficiently. - How do you handle class imbalance?
class_weightinfit, sample weights, resampling intf.data, focal loss, and metrics such as precision, recall and AUC instead of accuracy. - TensorFlow or PyTorch? TensorFlow's strengths are its deployment stack (Serving, LiteRT) and TPU support; PyTorch is widely used in research code. With Keras 3 you can switch backends. Interviewers want a reasoned choice, not loyalty.
- Which version changes should you know? 2.16: Keras 3 by default and
tf.estimatorremoved. 2.20: migrate fromtf.liteto LiteRT. 2.21: Python 3.9 support and the TensorBoard dependency removed.
TensorFlow scenario and troubleshooting questions
A tf.function keeps getting slower and logs retracing warnings. It is called with Python scalars or changing shapes. Pass tensors, add an input_signature with None dimensions, or set reduce_retracing=True.
Predictions in production differ from the notebook. Preprocessing differs between training and serving. Put preprocessing layers inside the model so the exported artifact carries them, and check the training flag.
The GPU is underused. The input pipeline cannot keep up. Add parallel map, cache and prefetch, use TFRecord files, and confirm with the profiler.
The loss becomes NaN. Check the learning rate, a from_logits mismatch, logs of zero, and a float16 output layer under mixed precision. tf.debugging.enable_check_numerics() finds the first bad op.
Old tutorial code fails on TensorFlow 2.16 or later. Keras 3 is now the default and tf.estimator is gone. Migrate to Keras 3 APIs: save with .keras files and export SavedModels with model.export; use tf-keras with TF_USE_LEGACY_KERAS=1 only as a stopgap.
How TensorFlow interviews test this
| Format | What it usually looks like | How to prepare |
|---|---|---|
| Concept Q&A | Eager versus graph, tf.function, GradientTape, Keras APIs, losses | Explain retracing and the training flag with examples |
| Live coding | Build and train a Keras model; write a custom training loop | Do both versions for one small dataset |
| ML system design | Input pipelines, distributed training, export and serving | Draw tf.data, strategy scope and SavedModel export end to end |
| Applied round | Transfer learning or a vision task | See computer vision interview questions |
Many teams also use PyTorch; PyTorch interview questions covers the same ground there.
Where CoPilot Interview fits
CoPilot Interview is an AI interview assistant. Its free AI mock interview builds TensorFlow and machine learning questions from your résumé and the job description, reads them aloud and scores each spoken answer out of 10, which is a fast way to find the answers above that you know but cannot yet explain cleanly under pressure. The browser demo has 145 practice questions in 10 tracks, scores typed answers out of 10 and needs no signup. The free plan gives 15 minutes a day of live help in sessions of up to 15 minutes, with AI mock interviews included. Paid plans are Standard at $24.99 a month and Pro at $39.99 a month, in the desktop app for Windows 10/11 and macOS 12 or later.
Use it to practice. Online assessments, proctored tests, take-home tasks with rules and AI-led rounds forbid outside help, so prepare for those instead of bringing a tool. For any live interview, follow your employer's rules.
Disclosure: CoPilot Interview is our product, so weigh what we say about it accordingly.
Frequently asked questions
What are the most common TensorFlow interview questions?
Eager execution versus tf.function, retracing, GradientTape, Sequential versus Functional versus subclassed models, callbacks, tf.data pipelines, distribution strategies, and saving and exporting models.
What is the latest TensorFlow version?
PyPI listed TensorFlow 2.21.0, released March 6, 2026, as the latest stable release on November 17, 2026, with 2.22.0rc1 available as a release candidate.
Is TensorFlow still used in 2026?
Yes, especially where its deployment tools (TF Serving, LiteRT) or TPUs matter, and Keras 3 lets teams keep one model API across TensorFlow, JAX and PyTorch backends.
What is the difference between tf.keras and Keras 3?
Since TensorFlow 2.16, tf.keras refers to Keras 3, the multi-backend version. The older Keras 2 lives on as the tf-keras package.
How do I prepare for a TensorFlow interview?
Build one model with fit and the same model with a GradientTape loop, add a tf.data pipeline with prefetching, export it with model.export, and explain each step aloud.
Practice this interview before the real one
The AI mock interview builds questions from your resume and the job description, reads them aloud and scores each spoken answer out of 10. Included on the free plan.
Start a mock interview