Challenge - 5 Problems
ONNX Runtime Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
ONNX Runtime Model Inference Output
What is the output shape of the prediction when running this ONNX Runtime code snippet on a model expecting input shape (1, 3, 224, 224)?
Computer Vision
import onnxruntime as ort import numpy as np session = ort.InferenceSession('model.onnx') input_name = session.get_inputs()[0].name input_data = np.random.randn(1, 3, 224, 224).astype(np.float32) outputs = session.run(None, {input_name: input_data}) prediction = outputs[0] print(prediction.shape)
Attempts:
2 left
💡 Hint
The model outputs class probabilities for 1000 classes in a batch of 1.
✗ Incorrect
The model expects a batch of images with shape (1, 3, 224, 224). The output is typically a batch of predictions with shape (batch_size, number_of_classes), here (1, 1000).
❓ Model Choice
intermediate1:30remaining
Choosing ONNX Runtime Execution Provider
Which ONNX Runtime execution provider should you choose to maximize inference speed on a machine with an NVIDIA GPU?
Attempts:
2 left
💡 Hint
NVIDIA GPUs are best supported by a specific provider.
✗ Incorrect
CUDAExecutionProvider uses NVIDIA GPU acceleration for faster inference. CPUExecutionProvider runs on CPU only. OpenVINO is for Intel hardware. TensorRT is also for NVIDIA but requires extra setup.
❓ Hyperparameter
advanced1:30remaining
Batch Size Effect on ONNX Runtime Performance
Increasing the batch size during ONNX Runtime inference usually has which effect on throughput and latency?
Attempts:
2 left
💡 Hint
Think about processing more inputs at once versus time per input.
✗ Incorrect
Larger batch sizes allow more inputs processed per second (higher throughput) but each batch takes longer to process (higher latency).
🔧 Debug
advanced2:00remaining
ONNX Runtime Input Type Error
What error will this ONNX Runtime code raise when passing input data as a Python list instead of a numpy array?
Computer Vision
import onnxruntime as ort session = ort.InferenceSession('model.onnx') input_name = session.get_inputs()[0].name input_data = [[0.5]*224]*224 # Python list, not numpy array outputs = session.run(None, {input_name: input_data})
Attempts:
2 left
💡 Hint
ONNX Runtime expects inputs as numpy arrays with correct dtype.
✗ Incorrect
Passing a Python list instead of a numpy array causes a TypeError because ONNX Runtime requires numpy.ndarray inputs.
🧠 Conceptual
expert2:30remaining
ONNX Runtime Model Optimization
Which ONNX Runtime feature allows you to optimize a model by fusing nodes and eliminating redundant operations to improve inference speed?
Attempts:
2 left
💡 Hint
This feature works on the model graph before running inference.
✗ Incorrect
Graph Optimization Level controls how ONNX Runtime optimizes the model graph by fusing nodes and removing redundancies to speed up inference.