How to use the smdebug.mxnet.Hook function in smdebug

To help you get started, we’ve selected a few smdebug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awslabs / sagemaker-debugger / tests / resources / mxnet / mnist_gluon_basic_hook_demo.py View on Github external
def create_hook(output_s3_uri):
    # With the following SaveConfig, we will save tensors for steps 1, 2 and 3
    # (indexing starts with 0).
    save_config = SaveConfig(save_steps=[1, 2, 3])

    # Create a hook that logs weights, biases and gradients while training the model.
    hook = Hook(
        out_dir=output_s3_uri,
        save_config=save_config,
        include_collections=["weights", "gradients", "biases"],
    )
    return hook
github awslabs / sagemaker-debugger / tests / core / test_hook_save_scalar.py View on Github external
def helper_mxnet_tests(collection, register_loss, save_config):
    coll_name, coll_regex = collection

    run_id = "trial_" + coll_name + "-" + datetime.now().strftime("%Y%m%d-%H%M%S%f")
    trial_dir = os.path.join(SMDEBUG_MX_HOOK_TESTS_DIR, run_id)

    hook = MX_Hook(
        out_dir=trial_dir,
        include_collections=[coll_name],
        save_config=save_config,
        export_tensorboard=True,
    )

    simple_mx_model(hook, register_loss=register_loss)
    hook.close()

    saved_scalars = ["scalar/mx_num_steps", "scalar/mx_before_train", "scalar/mx_after_train"]
    verify_files(trial_dir, save_config, saved_scalars)
github awslabs / sagemaker-debugger / examples / mxnet / scripts / mnist_gluon_realtime_visualize_demo.py View on Github external
def create_hook():
    # With the following SaveConfig, we will save tensors for every 100 steps
    save_config = SaveConfig(save_interval=100)

    # Create a hook that logs weights, biases and gradients while training the model.
    hook = Hook(save_config=save_config, save_all=True)
    return hook
github awslabs / sagemaker-debugger / examples / mxnet / scripts / mxnet_fashionmnist_w_g_b.py View on Github external
def create_hook(output_uri, save_frequency):
    # With the following SaveConfig, we will save tensors with the save_interval 100.
    save_config = SaveConfig(save_interval=save_frequency)

    # Create a hook that logs weights, biases and gradients while training the model.
    hook = Hook(
        out_dir=output_uri,
        save_config=save_config,
        include_collections=["weights", "gradients", "biases"],
    )
    return hook
github awslabs / sagemaker-debugger / examples / mxnet / scripts / mnist_mxnet.py View on Github external
def create_hook(output_uri):
    # With the following SaveConfig, we will save tensors for steps 1, 2 and 3
    # (indexing starts with 0).
    save_config = SaveConfig(save_interval=1)

    # Create a hook that logs weights, biases and gradients while training the model.
    hook = Hook(
        out_dir=output_uri,
        save_config=save_config,
        include_collections=["weights", "gradients", "biases"],
    )
    return hook
github awslabs / sagemaker-debugger / examples / mxnet / scripts / mnist_mxnet_hvd.py View on Github external
def create_hook():
    # With the following SaveConfig, we will save tensors for steps 1, 2 and 3
    # (indexing starts with 0).
    save_config = SaveConfig(save_interval=1)

    # Create a hook that logs weights, biases and gradients while training the model.
    ts_hook = Hook(
        out_dir=args.output_uri,
        save_config=save_config,
        include_collections=["weights", "gradients", "biases"],
    )
    return ts_hook
github awslabs / sagemaker-debugger / examples / mxnet / scripts / mnist_gluon_all_zero_demo.py View on Github external
def create_hook(output_s3_uri):
    # With the following SaveConfig, we will save tensors for steps 0, 1, 2 and 3
    # (indexing starts with 0).
    save_config = SaveConfig(save_steps=[0, 1, 2, 3])
    # Create a hook that logs weights, biases and gradients while training the model.
    hook = Hook(
        out_dir=output_s3_uri,
        save_config=save_config,
        include_collections=["ReluActivation", "weights", "biases", "gradients"],
    )
    hook.get_collection("ReluActivation").include(["relu*", "input_*"])
    return hook
github awslabs / sagemaker-debugger / examples / mxnet / scripts / mnist_gluon_model_input_output_demo.py View on Github external
def create_hook(output_s3_uri, block):
    # Create a SaveConfig that determines tensors from which steps are to be stored.
    # With the following SaveConfig, we will save tensors for steps 1, 2 and 3.
    save_config = SaveConfig(save_steps=[1, 2, 3])

    # Create a hook that logs weights, biases, gradients and inputs outputs of model while training.
    hook = Hook(
        out_dir=output_s3_uri,
        save_config=save_config,
        include_collections=["weights", "gradients", "biases", "TopBlock"],
    )

    # The names of input and output tensors of a block are in following format
    # Inputs :  _input_, and
    # Output :  _output
    # In order to log the inputs and output of a model, we will create a collection as follows:
    hook.get_collection("TopBlock").add_block_tensors(block, inputs=True, outputs=True)
    return hook