Docs

relax.docs.ListDocment

[source]

class relax.docs.ListDocment (tbl)

Initialize self. See help(type(self)) for accurate signature.

relax.docs.CustomizedMarkdownRenderer

[source]

class relax.docs.CustomizedMarkdownRenderer (sym, name=None, title_level=3)

Displaying documents of functions, classes, haiku.module, and BaseParser.

CustomizedMarkdownRenderer is the customized markdown render for the ReLax documentation site. We can use it to displaying documents of functions, classes, haiku.module, and BaseParser.

We can display documentations for functions:

def validate_config(
    configs: Dict|BaseParser, # A configuration of the model/data.
    config_cls: BaseParser # The desired configuration class.
) -> BaseParser:
    """Return a valid configuration object."""
    ...

CustomizedMarkdownRenderer(validate_config)

validate_config

validate_config (configs, config_cls)

Return a valid configuration object.

Parameters:

  • configs (Dict | BaseParser) – A configuration of the model/data.
  • config_cls (BaseParser) – The desired configuration class.

Returns:

    (BaseParser)

We can display documentations for classes:

class VanillaCF:
    """VanillaCF Explanation of the model."""

    def __init__(
        self, 
        configs: Dict|BaseParser=None # A configuration of the model.
    ): ...

    def generate_cf(
        self,
        x: np.ndarray, # A data point.
        pred_fn: Callable, # A prediction function.
    ) -> Array:
        """Generate counterfactuals for the given data point."""
        pass

    __ALL__ = ["generate_cf"]
CustomizedMarkdownRenderer(VanillaCF)

relax.methods.vanilla.VanillaCF

[source]

class relax.methods.vanilla.VanillaCF (configs=None)

VanillaCF Explanation of the model.

Parameters:

  • configs (Dict | BaseParser, default=None) – A configuration of the model.

Methods

[source]

generate_cf (x, pred_fn)

Generate counterfactuals for the given data point.

Parameters:

  • x (np.ndarray) – A data point.
  • pred_fn (Callable) – A prediction function.

Returns:

    (Array)


We can display documentations for BaseParser:

class VanillaCFConfig(BaseParser):
    """Configuration for the `Model`."""
    pass

CustomizedMarkdownRenderer(VanillaCFConfig)

relax.methods.vanilla.VanillaCFConfig

[source]

class relax.methods.vanilla.VanillaCFConfig ()

Configuration for the Model.

class VanillaCFConfig(BaseParser):
    """Configuration for the `Model`."""

    lr: float = Field(1e-3, description="Learning rate.")
    n_steps: int = Field(100, description="Number of iteration steps.")

CustomizedMarkdownRenderer(VanillaCFConfig)

relax.methods.vanilla.VanillaCFConfig

[source]

class relax.methods.vanilla.VanillaCFConfig (lr=0.001, n_steps=100)

Configuration for the Model.

Parameters:

  • lr (float, default=0.001) – Learning rate.
  • n_steps (int, default=100) – Number of iteration steps.