0
0
PyTorchml~10 mins

TorchServe setup in PyTorch - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the TorchServe handler module.

PyTorch
from ts.torch_handler import [1]
Drag options to blanks, or click blank then click option'
Abase_handler
Btorchserve
Cmodel_handler
Dserve
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to import torchserve or serve which are not modules in ts.torch_handler.
Using model_handler which is not a standard import.
2fill in blank
medium

Complete the command to start TorchServe with a model store directory.

PyTorch
torchserve --start --model-store [1] --models my_model.mar
Drag options to blanks, or click blank then click option'
A/tmp/model_store
B/models
C/home/user/models
D/var/model
Attempts:
3 left
💡 Hint
Common Mistakes
Using a directory that does not exist or is not accessible.
Omitting the --model-store option.
3fill in blank
hard

Fix the error in the handler class definition by completing the base class name.

PyTorch
class MyHandler([1]):
    def __init__(self):
        super().__init__()
Drag options to blanks, or click blank then click option'
AHandlerBase
BBaseHandler
CTorchHandler
DModelHandler
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect base class names like HandlerBase or TorchHandler.
Forgetting to call super().__init__() in the constructor.
4fill in blank
hard

Fill both blanks to create a dictionary mapping model names to their .mar files for TorchServe registration.

PyTorch
models = [1]: '[2].mar' for [1] in ['resnet18', 'bert']}
Drag options to blanks, or click blank then click option'
Amodel_name
Bmodel
Cresnet18
Dbert
Attempts:
3 left
💡 Hint
Common Mistakes
Using fixed strings instead of variables in the comprehension.
Mixing variable names between key and value.
5fill in blank
hard

Fill all three blanks to define a TorchServe model archive creation command with model file, handler, and export path.

PyTorch
torch-model-archiver --model-name [1] --version 1.0 --serialized-file [2] --handler [3] --export-path model_store
Drag options to blanks, or click blank then click option'
Aresnet18
Bresnet18.pth
Cimage_classifier
Dbert
Ebert.pth
Ftext_classifier
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing model names and handlers from different model types.
Using incorrect file names or handler names.