tensorflow/models

View on GitHub
research/efficient-hrl/agents/ddpg_agent.py

Summary

Maintainability
F
1 wk
Test Coverage

File ddpg_agent.py has 633 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2018 The TensorFlow Authors All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Major
Found in research/efficient-hrl/agents/ddpg_agent.py - About 1 day to fix

    Function __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def __init__(self,
    Severity: Major
    Found in research/efficient-hrl/agents/ddpg_agent.py - About 1 hr to fix

      Function __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def __init__(self,
      Severity: Major
      Found in research/efficient-hrl/agents/ddpg_agent.py - About 1 hr to fix

        Function critic_loss has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def critic_loss(self, states, actions, rewards, discounts,
        Severity: Minor
        Found in research/efficient-hrl/agents/ddpg_agent.py - About 35 mins to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            @gin.configurable('ddpg_update_targets')
            def update_targets(self, tau=1.0):
              """Performs a soft update of the target network parameters.
          
              For each weight w_s in the actor/critic networks, and its corresponding
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 1 other location - About 1 day to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 675..705

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 156.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            @gin.configurable('td3_update_targets')
            def update_targets(self, tau=1.0):
              """Performs a soft update of the target network parameters.
          
              For each weight w_s in the actor/critic networks, and its corresponding
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 1 other location - About 1 day to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 408..437

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 156.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              with tf.name_scope('target_q_values'):
                tf.summary.scalar('mean', tf.reduce_mean(target_q_values))
                tf.summary.scalar('max', tf.reduce_max(target_q_values))
                tf.summary.scalar('min', tf.reduce_min(target_q_values))
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 2 other locations - About 3 hrs to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 723..726
          research/efficient-hrl/agents/ddpg_agent.py on lines 727..730

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 64.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              with tf.name_scope('td_targets'):
                tf.summary.scalar('mean', tf.reduce_mean(td_targets))
                tf.summary.scalar('max', tf.reduce_max(td_targets))
                tf.summary.scalar('min', tf.reduce_min(td_targets))
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 2 other locations - About 3 hrs to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 727..730
          research/efficient-hrl/agents/ddpg_agent.py on lines 731..734

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 64.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              with tf.name_scope('q_values'):
                tf.summary.scalar('mean', tf.reduce_mean(q_values))
                tf.summary.scalar('max', tf.reduce_max(q_values))
                tf.summary.scalar('min', tf.reduce_min(q_values))
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 2 other locations - About 3 hrs to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 723..726
          research/efficient-hrl/agents/ddpg_agent.py on lines 731..734

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 64.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def _validate_actions(self, actions):
              """Raises a value error if `actions` does not have the expected shape.
          
              Args:
                actions: A tensor.
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 1 other location - About 3 hrs to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 475..488

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def _validate_states(self, states):
              """Raises a value error if `states` does not have the expected shape.
          
              Args:
                states: A tensor.
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 1 other location - About 3 hrs to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 490..503

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if self._target_q_clipping is not None:
                td_targets = tf.clip_by_value(td_targets, self._target_q_clipping[0],
                                              self._target_q_clipping[1])
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 1 other location - About 1 hr to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 331..334

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 41.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                if self._target_q_clipping is not None:
                  residual_td_targets = tf.clip_by_value(residual_td_targets,
                                                         self._target_q_clipping[0],
                                                         self._target_q_clipping[1])
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 1 other location - About 1 hr to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 317..319

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 41.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            def target_value_net(self, states, for_critic_loss=False):
              """Returns the output of the target critic evaluated with the target actor.
          
              Args:
                states: A [batch_size, num_state_dims] tensor representing a batch
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 2 other locations - About 1 hr to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 261..271
          research/efficient-hrl/agents/ddpg_agent.py on lines 644..654

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 38.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            def value_net(self, states, for_critic_loss=False):
              """Returns the output of the critic evaluated with the actor.
          
              Args:
                states: A [batch_size, num_state_dims] tensor representing a batch
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 2 other locations - About 1 hr to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 274..284
          research/efficient-hrl/agents/ddpg_agent.py on lines 644..654

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 38.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            def value_net(self, states, for_critic_loss=False):
              """Returns the output of the critic evaluated with the actor.
          
              Args:
                states: A [batch_size, num_state_dims] tensor representing a batch
          Severity: Major
          Found in research/efficient-hrl/agents/ddpg_agent.py and 2 other locations - About 1 hr to fix
          research/efficient-hrl/agents/ddpg_agent.py on lines 261..271
          research/efficient-hrl/agents/ddpg_agent.py on lines 274..284

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 38.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if self._dqda_clipping > 0:
                dqda = tf.clip_by_value(dqda, -self._dqda_clipping, self._dqda_clipping)
          Severity: Minor
          Found in research/efficient-hrl/agents/ddpg_agent.py and 1 other location - About 35 mins to fix
          official/legacy/xlnet/xlnet_modeling.py on lines 693..695

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 33.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status