tensorflow/models

View on GitHub

Showing 11,634 of 11,634 total issues

Function update_stats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def update_stats(history, stats, callbacks):
  """Normalizes and updates dictionary of stats.

  Args:
    history: Results of the training step.
Severity: Minor
Found in official/legacy/transformer/misc.py - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

          if not feature.token_is_max_context.get(start_index, False):
            continue
          if end_index < start_index:
Severity: Major
Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

              if not is_impossible:
                answer = qa["answers"][0]
                orig_answer_text = answer["text"]
                start_position = answer["answer_start"]
              else:
    Severity: Major
    Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if train_metric:
                  tf.summary.scalar(
                      train_metric.name,
                      _float_metric_value(train_metric),
                      step=current_step)
      Severity: Major
      Found in official/legacy/xlnet/training_utils.py - About 45 mins to fix

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

          def __init__(self, hidden_size, start_n_top, end_n_top, initializer,
        Severity: Minor
        Found in official/legacy/xlnet/xlnet_modeling.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if correct_strip:
                      line = native_to_unicode(line)
                    line = line.strip()
          Severity: Major
          Found in official/legacy/transformer/utils/tokenizer.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      for token in _split_string_to_tokens(
                          native_to_unicode(line), master_char_set):
                        token_counts[token] += 1
              return token_counts
            Severity: Major
            Found in official/legacy/transformer/utils/tokenizer.py - About 45 mins to fix

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

                def __init__(self, xlnet_config, run_config, n_class, summary_type,
              Severity: Minor
              Found in official/legacy/xlnet/xlnet_modeling.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if "model/transformer/layer_{}/".format(l) in tvars[i].name:
                              abs_rate = input_meta_data["lr_layer_decay_rate"]**(
                                  n_layer - 1 - l)
                              clipped[i] *= abs_rate
                              logging.info("Apply mult {:.4f} to layer-{} grad of {}".format(
                Severity: Major
                Found in official/legacy/xlnet/training_utils.py - About 45 mins to fix

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

                    def __init__(self, xlnet_config, run_config, start_n_top, end_n_top,
                  Severity: Minor
                  Found in official/legacy/xlnet/xlnet_modeling.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                for metric_obj in train_metrics:
                                  tf.summary.scalar(metric_obj.name, metric_obj.result(),
                                                    current_step)
                                  summary_writer.flush()
                    
                    
                    Severity: Major
                    Found in official/legacy/transformer/transformer_main.py - About 45 mins to fix

                      Function call has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def call(self,
                      Severity: Minor
                      Found in official/legacy/transformer/attention_layer.py - About 45 mins to fix

                        Function run_evaluation has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def run_evaluation(strategy,
                        Severity: Minor
                        Found in official/legacy/xlnet/run_classifier.py - About 45 mins to fix

                          Function format_filename has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def format_filename(prefix,
                          Severity: Minor
                          Found in official/legacy/xlnet/data_utils.py - About 45 mins to fix

                            Function get_dataset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def get_dataset(params, num_hosts, num_core_per_host, split, file_names,
                                            num_batch, seq_len, reuse_len, perm_size, mask_alpha,
                                            mask_beta, use_bfloat16=False, num_predict=None):
                              """Gets the dataset."""
                            
                            
                            Severity: Minor
                            Found in official/legacy/xlnet/preprocess_pretrain_data.py - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function file_based_convert_examples_to_features has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def file_based_convert_examples_to_features(examples,
                                                                        label_list,
                                                                        max_seq_length,
                                                                        tokenize_fn,
                                                                        output_file,
                            Severity: Minor
                            Found in official/legacy/xlnet/preprocess_classification_data.py - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function _convert_example has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def _convert_example(example, use_bfloat16):
                              """Cast int64 into int32 and float32 to bfloat16 if use_bfloat16."""
                              for key in list(example.keys()):
                                val = example[key]
                                if tf_keras.backend.is_sparse(val):
                            Severity: Minor
                            Found in official/legacy/xlnet/preprocess_pretrain_data.py - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function _split_string_to_tokens has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def _split_string_to_tokens(text, master_char_set):
                              """Splits text to a list of string tokens."""
                              if not text:
                                return []
                              ret = []
                            Severity: Minor
                            Found in official/legacy/transformer/utils/tokenizer.py - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function evaluate_and_log_bleu has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def evaluate_and_log_bleu(model,
                            Severity: Minor
                            Found in official/legacy/transformer/transformer_main.py - About 45 mins to fix

                              Function get_synth_input_fn has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              def get_synth_input_fn(height,
                              Severity: Minor
                              Found in official/legacy/image_classification/resnet/common.py - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language