DP-100 · Question #19
DP-100 Question #19: Real Exam Question with Answer & Explanation
The user needs to select and order code segments to correctly import and instantiate the TruncationSelectionPolicy for early stopping in Azure ML's hyperdrive.
Question
Drag and Drop Question You need to implement an early stopping criteria policy for model training. Which three code segments should you use to develop the solution? To answer, move the appropriate code segments from the list of code segments to the answer area and arrange them in the correct order. NOTE: More than one order of answer choices is correct. You will receive credit for any of the correct orders you select. Answer:
Explanation
The user needs to select and order code segments to correctly import and instantiate the TruncationSelectionPolicy for early stopping in Azure ML's hyperdrive.
Approach. The goal is to implement an early stopping policy using TruncationSelectionPolicy. To achieve this, the necessary steps are to first specify the module from which to import, then import the specific class, and finally, instantiate that class. The correct interaction involves dragging the following three code segments into the 'Answer Area' in the specified order:
- 'from azureml.train.hyperdrive': This specifies the module within Azure ML from which the early stopping policies are imported.
- 'import TruncationSelectionPolicy': This imports the specific
TruncationSelectionPolicyclass from the previously specified module. - 'early_termination_policy = TruncationSelectionPolicy(evaluation_interval=1, truncation_percentage=20, delay_evaluation=5)': This instantiates the
TruncationSelectionPolicywith the given parameters, which define how the early stopping criteria will be applied during hyperparameter tuning, and assigns it to theearly_termination_policyvariable.
This order ensures that the required class is correctly imported and available in the scope before it is used to create an object, following standard Python syntax and execution flow.
Common mistakes.
- common_mistake. A common mistake is selecting code segments related to
BanditPolicyinstead ofTruncationSelectionPolicy. WhileBanditPolicyis also an early stopping policy, the question provides a complete set of code forTruncationSelectionPolicy, making it the intended solution. Another mistake would be to place the instantiation of theTruncationSelectionPolicybefore its import (e.g., placingearly_termination_policy = TruncationSelectionPolicy(...)before thefromandimportstatements), which would lead to aNameErrorbecause the class would not be defined yet. Incorrectly ordering thefromandimportstatements (e.g., placingimport TruncationSelectionPolicybeforefrom azureml.train.hyperdrive) would also be syntactically incorrect in Python, as these two parts combine to form a single, valid import statement (from module import class).
Concept tested. Azure Machine Learning Hyperdrive, early stopping policies (specifically TruncationSelectionPolicy), Python module import mechanisms, and object instantiation.
Topics
Community Discussion
No community discussion yet for this question.