nerdexam
Google

PROFESSIONAL-MACHINE-LEARNING-ENGINEER · Question #45

Your team needs to build a model that predicts whether images contain a driver's license, passport, or credit card. The data engineering team already built the pipeline and generated a dataset compose

The correct answer is C. Categorical cross-entropy. Use sparse categorical crossentropy when your classes are mutually exclusive (e.g. when each sample belongs exactly to one class) and categorical crossentropy when one sample can have multiple classes or labels are soft probabilities (like [0.5, 0.3, 0.2]).

Submitted by chen.hong· Apr 18, 2026ML model development

Question

Your team needs to build a model that predicts whether images contain a driver's license, passport, or credit card. The data engineering team already built the pipeline and generated a dataset composed of 10,000 images with driver's licenses, 1,000 images with passports, and 1,000 images with credit cards. You now have to train a model with the following label map: [drivers_license', passport', `credit_card']. Which loss function should you use?

Options

  • ACategorical hinge
  • BBinary cross-entropy
  • CCategorical cross-entropy
  • DSparse categorical cross-entropy

How the community answered

(43 responses)
  • A
    2% (1)
  • B
    2% (1)
  • C
    88% (38)
  • D
    7% (3)

Explanation

Use sparse categorical crossentropy when your classes are mutually exclusive (e.g. when each sample belongs exactly to one class) and categorical crossentropy when one sample can have multiple classes or labels are soft probabilities (like [0.5, 0.3, 0.2]).

Topics

#Loss Functions#Multi-class Classification#Model Training

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-MACHINE-LEARNING-ENGINEER Practice