Configure tensor collections using the CollectionConfig API
Note
After careful consideration, we have made the decision to close new customer access to Amazon Sagemaker Debugger, effective 7/30/26. Existing customers can continue to use the service as normal. Amazon continues to invest in security and availability improvements for Debugger, but we do not plan to introduce new features. For more information, see Debugger availability change.
Use the CollectionConfig API operation to configure tensor
collections. Debugger provides pre-built tensor collections that cover a variety of
regular expressions (regex) of parameters if using Debugger-supported deep learning
frameworks and machine learning algorithms. As shown in the following example code,
add the built-in tensor collections you want to debug.
from sagemaker.core.debugger import CollectionConfig collection_configs=[ CollectionConfig(name="weights"), CollectionConfig(name="gradients") ]
The preceding collections set up the Debugger hook to save the tensors every 500
steps based on the default "save_interval" value.
For a full list of available Debugger built-in collections, see Debugger Built-in Collections
If you want to customize the built-in collections, such as changing the save
intervals and tensor regex, use the following CollectionConfig template
to adjust parameters.
from sagemaker.core.debugger import CollectionConfig collection_configs=[ CollectionConfig( name="tensor_collection", parameters={ "key_1": "value_1", "key_2": "value_2", ... "key_n": "value_n" } ) ]
For more information about available parameter keys, see CollectionConfig
from sagemaker.core.debugger import CollectionConfig collection_configs=[ CollectionConfig( name="losses", parameters={ "train.save_interval": "100", "eval.save_interval": "10" } ) ]
Tip
This tensor collection configuration object can be used for both DebuggerHookConfig and Rule API operations.