PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers
|Home/Machine Learning/NVIDIA

Derive MLP shapes and explain PyTorch broadcasting

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of tensor shapes, linear layer forward computation, and deep-learning-framework broadcasting semantics. It is commonly asked to confirm practical ability to translate mathematical layer definitions into concrete tensor shapes and to reason about broadcasting behavior; it belongs to the Machine Learning domain and tests practical application of tensor algebra grounded in conceptual understanding.

  • medium
  • NVIDIA
  • Machine Learning
  • Software Engineer

Derive MLP shapes and explain PyTorch broadcasting

Company: NVIDIA

Role: Software Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

You are given a standard MLP layer (fully connected layer) used in deep learning. 1. Write the forward computation for a linear layer with bias. 2. Given input tensor shapes, determine output shapes and explain how **bias broadcasting** works in PyTorch. Assume: - Input `x` has shape `(B, Din)` (batch size `B`). - The layer has output dimension `Dout`. Answer the following: - What are the shapes of `weight` and `bias` in `torch.nn.Linear(Din, Dout)`? - What is the output shape? - How does this generalize if `x` has shape `(B, T, Din)` (e.g., sequence length `T`)? - What broadcasting rule makes `bias` add correctly?

Quick Answer: This question evaluates understanding of tensor shapes, linear layer forward computation, and deep-learning-framework broadcasting semantics. It is commonly asked to confirm practical ability to translate mathematical layer definitions into concrete tensor shapes and to reason about broadcasting behavior; it belongs to the Machine Learning domain and tests practical application of tensor algebra grounded in conceptual understanding.

Related Interview Questions

  • Explain bias-variance, calibration, and model drift - NVIDIA (medium)
  • Diagnose overfitting, DenseNet, preprocessing, CV - NVIDIA (hard)
  • Analyze overfitting, DenseNet, preprocessing, and cross-validation - NVIDIA (hard)
  • Explain optimization and tensor vs pipeline parallelism - NVIDIA (hard)
  • Compare ML frameworks and trends - NVIDIA (medium)
NVIDIA logo
NVIDIA
Jan 14, 2026, 12:00 AM
Software Engineer
Technical Screen
Machine Learning
3
0
Loading...

You are given a standard MLP layer (fully connected layer) used in deep learning.

  1. Write the forward computation for a linear layer with bias.
  2. Given input tensor shapes, determine output shapes and explain how bias broadcasting works in PyTorch.

Assume:

  • Input x has shape (B, Din) (batch size B ).
  • The layer has output dimension Dout .

Answer the following:

  • What are the shapes of weight and bias in torch.nn.Linear(Din, Dout) ?
  • What is the output shape?
  • How does this generalize if x has shape (B, T, Din) (e.g., sequence length T )?
  • What broadcasting rule makes bias add correctly?

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Machine Learning•More NVIDIA•More Software Engineer•NVIDIA Software Engineer•NVIDIA Machine Learning•Software Engineer Machine Learning
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • Careers
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.