question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Naming inconsistency

See original GitHub issue

Describe the bug I found that some names agruments in framework aren’t consistent. So for example:

class SupervisedRunner(Runner):
    """Runner for experiments with supervised model."""

    _experiment_fn: Callable = SupervisedExperiment

    def __init__(
        self,
        model: Model = None,
        device: Device = None,
        input_key: Any = "features", 
        output_key: Any = "logits",
        input_target_key: str = "targets", # This argument corresponds to input_key argument in CriterionCallback
    ):

class CriterionCallback(_MetricCallback):
    """Callback for that measures loss with specified criterion."""

    def __init__(
        self,
        input_key: Union[str, List[str], Dict[str, str]] = "targets", # This argument corresponds to input_target_key argument in SupervisedRunner
        output_key: Union[str, List[str], Dict[str, str]] = "logits",
        prefix: str = "loss",
        criterion_key: str = None,
        multiplier: float = 1.0,
        **metric_kwargs,
    ):

To Reproduce Steps to reproduce the behavior:

  1. Check files: catalyst.core.callback.metric.py and catalyst.dl.runner.supervised.py

Expected behavior I expect that names would be consistent across the framework and means the same

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
ogvaltcommented, Apr 27, 2020

How it now

input_target_key corresponds to input_key argument in CriterionCallback input_target_key: str = "targets"

input_key corresponds to input_target_key argument in SupervisedRunner input_key: Union[str, List[str], Dict[str, str]] = "targets"

class SupervisedRunner(Runner):
    """Runner for experiments with supervised model."""

    _experiment_fn: Callable = SupervisedExperiment

    def __init__(
        self,
        model: Model = None,
        device: Device = None,
        input_key: Any = "features", 
        output_key: Any = "logits",
        # !!!input_target_key corresponds to input_key argument in CriterionCallback!!!
        input_target_key: str = "targets", 
    ):

class CriterionCallback(_MetricCallback):
    """Callback for that measures loss with specified criterion."""

    def __init__(
        self,
        # !!!input_key corresponds to input_target_key argument in SupervisedRunner!!!
        input_key: Union[str, List[str], Dict[str, str]] = "targets",         
        output_key: Union[str, List[str], Dict[str, str]] = "logits",
        prefix: str = "loss",
        criterion_key: str = None,
        multiplier: float = 1.0,
        **metric_kwargs,
    ):

How it should

Since CriterionCallback calcucates criterion between target (or input_target_key) and output_key it should be better to rename input_key to input_target_key as in the SupervisedRunner


class CriterionCallback(_MetricCallback):
    """Callback for that measures loss with specified criterion."""

    def __init__(
        self,
        # previous version
        input_key: Union[str, List[str], Dict[str, str]] = "targets", 
        # suggested version
        input_target_key: Union[str, List[str], Dict[str, str]] = "targets",         
        ...
    ):

Also I suggest to check this across whole framework

0reactions
stale[bot]commented, Nov 23, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code Inspection: Inconsistent Naming - ReSharper - JetBrains
This inspection notifies you about violations of symbol naming style whether you use the default set of naming rules or configure your ...
Read more >
CWE-1099: Inconsistent Naming Conventions for Identifiers (4.9)
CWE-1099: Inconsistent Naming Conventions for Identifiers ; ChildOf, Class - a weakness that is described in a very abstract fashion, typically ...
Read more >
Finding Non-trivial Malware Naming Inconsistencies - SysSec
Clearly, solving naming inconsistencies is a very difficult task, as it requires that vendors agree on a unified naming convention.
Read more >
Bad Habits to Kick : Inconsistent naming conventions
In this post, I want to treat the use of inconsistent naming conventions. Stored Procedures. In one of the systems I've inherited, ...
Read more >
Inconsistency in naming of SQL agent collector - IBM
Cause. While upgrading the SQL agent from version 6.2.3 (or lower) to version 6.3.1, the collector service name will be renamed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found