tensorflow/models

View on GitHub
research/pcl_rl/objective.py

Summary

Maintainability
F
4 days
Test Coverage

File objective.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2017 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: Minor
Found in research/pcl_rl/objective.py - About 2 hrs to fix

    Function get has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get(self, rewards, pads, values, final_values,
              log_probs, prev_log_probs, target_log_probs,
              entropies, logits,
              target_values, final_target_values):
        not_pad = 1 - pads
    Severity: Minor
    Found in research/pcl_rl/objective.py - About 1 hr to fix

      Function get has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def get(self, rewards, pads, values, final_values,
      Severity: Major
      Found in research/pcl_rl/objective.py - About 1 hr to fix

        Function get has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def get(self, rewards, pads, values, final_values,
        Severity: Major
        Found in research/pcl_rl/objective.py - About 1 hr to fix

          Function get has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def get(self, rewards, pads, values, final_values,
          Severity: Major
          Found in research/pcl_rl/objective.py - About 1 hr to fix

            Function get has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def get(self, rewards, pads, values, final_values,
            Severity: Major
            Found in research/pcl_rl/objective.py - About 1 hr to fix

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

                def __init__(self, learning_rate, clip_norm=5,
              Severity: Major
              Found in research/pcl_rl/objective.py - About 1 hr to fix

                Function get has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def get(self, rewards, pads, values, final_values,
                          log_probs, prev_log_probs, target_log_probs,
                          entropies, logits,
                          target_values, final_target_values):
                    not_pad = 1 - pads
                Severity: Minor
                Found in research/pcl_rl/objective.py - About 1 hr to fix

                  Function get has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def get(self, rewards, pads, values, final_values,
                            log_probs, prev_log_probs, target_log_probs,
                            entropies, logits,
                            target_values, final_target_values):
                      not_pad = 1 - pads
                  Severity: Minor
                  Found in research/pcl_rl/objective.py - About 1 hr to fix

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

                        value_estimates = tf.concat(
                            [self.gamma ** tf.expand_dims(
                                tf.range(float(self.rollout - 1), 0, -1), 1) *
                             tf.ones([self.rollout - 1, batch_size]) *
                             value_estimates[0:1, :],
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 1 other location - About 5 hrs to fix
                    research/pcl_rl/objective.py on lines 228..233

                    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 90.

                    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

                        target_values = tf.concat(
                            [self.gamma ** tf.expand_dims(
                                tf.range(float(self.rollout - 1), 0, -1), 1) *
                             tf.ones([self.rollout - 1, batch_size]) *
                             target_values[0:1, :],
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 1 other location - About 5 hrs to fix
                    research/pcl_rl/objective.py on lines 216..221

                    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 90.

                    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

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

                      conv_values = tf.transpose(tf.squeeze(tf.nn.conv1d(
                          tf.expand_dims(tf.transpose(expanded_values), -1), discount_filter,
                          stride=1, padding='VALID'), -1))
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 1 other location - About 1 hr to fix
                    research/pcl_rl/objective.py on lines 62..64

                    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 47.

                    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

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

                      conv_values = tf.transpose(tf.squeeze(tf.nn.conv1d(
                          tf.expand_dims(tf.transpose(expanded_values), -1), discount_filter,
                          stride=1, padding='VALID'), -1))
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 1 other location - About 1 hr to fix
                    research/pcl_rl/objective.py on lines 78..80

                    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 47.

                    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

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

                        if self.use_target_values:
                          last_values = shift_values(
                              target_values, self.gamma, self.rollout,
                              final_target_values)
                        else:
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 2 other locations - About 1 hr to fix
                    research/pcl_rl/objective.py on lines 241..247
                    research/pcl_rl/objective.py on lines 316..322

                    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 39.

                    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

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

                        if self.use_target_values:
                          last_values = shift_values(
                              target_values, self.gamma, self.rollout,
                              final_target_values)
                        else:
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 2 other locations - About 1 hr to fix
                    research/pcl_rl/objective.py on lines 138..144
                    research/pcl_rl/objective.py on lines 316..322

                    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 39.

                    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

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

                        if self.use_target_values:
                          last_values = shift_values(
                              target_values, self.gamma, self.rollout,
                              final_target_values)
                        else:
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 2 other locations - About 1 hr to fix
                    research/pcl_rl/objective.py on lines 138..144
                    research/pcl_rl/objective.py on lines 241..247

                    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 39.

                    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

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

                        if self.clip_adv:
                          adv = tf.minimum(self.clip_adv, tf.maximum(-self.clip_adv, adv))
                    Severity: Minor
                    Found in research/pcl_rl/objective.py and 2 other locations - About 35 mins to fix
                    research/pcl_rl/objective.py on lines 150..151
                    research/pcl_rl/objective.py on lines 329..330

                    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

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

                        if self.clip_adv:
                          adv = tf.minimum(self.clip_adv, tf.maximum(-self.clip_adv, adv))
                    Severity: Minor
                    Found in research/pcl_rl/objective.py and 2 other locations - About 35 mins to fix
                    research/pcl_rl/objective.py on lines 150..151
                    research/pcl_rl/objective.py on lines 256..257

                    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

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

                        if self.clip_adv:
                          adv = tf.minimum(self.clip_adv, tf.maximum(-self.clip_adv, adv))
                    Severity: Minor
                    Found in research/pcl_rl/objective.py and 2 other locations - About 35 mins to fix
                    research/pcl_rl/objective.py on lines 256..257
                    research/pcl_rl/objective.py on lines 329..330

                    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

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

                        not_pad = tf.concat([tf.ones([self.rollout - 1, batch_size]),
                                             not_pad], 0)
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 4 other locations - About 30 mins to fix
                    research/pcl_rl/objective.py on lines 214..215
                    research/pcl_rl/objective.py on lines 222..223
                    research/pcl_rl/objective.py on lines 224..225
                    research/pcl_rl/objective.py on lines 226..227

                    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 32.

                    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 5 locations. Consider refactoring.
                    Open

                        log_probs = tf.concat([tf.zeros([self.rollout - 1, batch_size]),
                                               log_probs], 0)
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 4 other locations - About 30 mins to fix
                    research/pcl_rl/objective.py on lines 212..213
                    research/pcl_rl/objective.py on lines 214..215
                    research/pcl_rl/objective.py on lines 224..225
                    research/pcl_rl/objective.py on lines 226..227

                    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 32.

                    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 5 locations. Consider refactoring.
                    Open

                        rewards = tf.concat([tf.zeros([self.rollout - 1, batch_size]),
                                             rewards], 0)
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 4 other locations - About 30 mins to fix
                    research/pcl_rl/objective.py on lines 212..213
                    research/pcl_rl/objective.py on lines 222..223
                    research/pcl_rl/objective.py on lines 224..225
                    research/pcl_rl/objective.py on lines 226..227

                    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 32.

                    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 5 locations. Consider refactoring.
                    Open

                        relative_log_probs = tf.concat([tf.zeros([self.rollout - 1, batch_size]),
                                                        relative_log_probs], 0)
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 4 other locations - About 30 mins to fix
                    research/pcl_rl/objective.py on lines 212..213
                    research/pcl_rl/objective.py on lines 214..215
                    research/pcl_rl/objective.py on lines 222..223
                    research/pcl_rl/objective.py on lines 224..225

                    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 32.

                    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 5 locations. Consider refactoring.
                    Open

                        prev_log_probs = tf.concat([tf.zeros([self.rollout - 1, batch_size]),
                                                    prev_log_probs], 0)
                    Severity: Major
                    Found in research/pcl_rl/objective.py and 4 other locations - About 30 mins to fix
                    research/pcl_rl/objective.py on lines 212..213
                    research/pcl_rl/objective.py on lines 214..215
                    research/pcl_rl/objective.py on lines 222..223
                    research/pcl_rl/objective.py on lines 226..227

                    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 32.

                    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