oujago/NumpyDL

View on GitHub

Showing 63 of 162 total issues

File recurrent.py has 557 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-


import numpy as np

Severity: Major
Found in npdl/layers/recurrent.py - About 1 day to fix

    File optimizers.py has 371 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Functions to generate Theano update dictionaries for training.
    
    The update functions implement different methods to control the learning
    rate for use with stochastic gradient descent.
    Severity: Minor
    Found in npdl/optimizers.py - About 4 hrs to fix

      Function backward has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def backward(self, pre_grad, *args, **kwargs):
      
              # shape
              assert pre_grad.shape == self.last_output.shape
              nb_batch, input_depth, old_img_h, old_img_w = self.last_input.shape
      Severity: Minor
      Found in npdl/layers/convolution.py - About 4 hrs 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

      File activations.py has 357 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      
      """
      Non-linear activation functions for artificial neurons.
      
      
      Severity: Minor
      Found in npdl/activations.py - About 4 hrs to fix

        Function backward has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            def backward(self, pre_grad, *args, **kwargs):
                self.dW = _zero(self.W.shape)
                self.dU = _zero(self.U.shape)
                self.db = _zero(self.b.shape)
        
        
        Severity: Minor
        Found in npdl/layers/recurrent.py - About 4 hrs 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 forward has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def forward(self, input, *args, **kwargs):
        
                # shape
                self.input_shape = input.shape
                pool_h, pool_w = self.pool_size
        Severity: Minor
        Found in npdl/layers/pooling.py - About 3 hrs 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 backward has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def backward(self, pre_grad, *args, **kwargs):
                new_h, new_w = self.out_shape[-2:]
                pool_h, pool_w = self.pool_size
        
                layer_grads = _zero(self.input_shape)
        Severity: Minor
        Found in npdl/layers/pooling.py - About 3 hrs 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 backward has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def backward(self, pre_grad, *args, **kwargs):
                new_h, new_w = self.out_shape[-2:]
                pool_h, pool_w = self.pool_size
                length = np.prod(self.pool_size)
        
        Severity: Minor
        Found in npdl/layers/pooling.py - About 3 hrs 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 forward has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def forward(self, input, *args, **kwargs):
                # shape
                self.input_shape = input.shape
                pool_h, pool_w = self.pool_size
                new_h, new_w = self.out_shape[-2:]
        Severity: Minor
        Found in npdl/layers/pooling.py - About 3 hrs 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 get has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        def get(initialization):
            if initialization.__class__.__name__ == 'str':
                if initialization in ['zero', 'Zero']:
                    return Zero()
                if initialization in ['one', 'One']:
        Severity: Minor
        Found in npdl/initializations.py - About 3 hrs 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 fit has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            def fit(self, X, Y, max_iter=100, batch_size=64, shuffle=True,
                    validation_split=0., validation_data=None, file=sys.stdout):
        
                # prepare data
                train_X = X.astype(get_dtype()) if np.issubdtype(np.float64, X.dtype) else X
        Severity: Minor
        Found in npdl/model.py - About 3 hrs 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 get has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

        def get(activation):
            if activation.__class__.__name__ == 'str':
                if activation in ['sigmoid', 'Sigmoid']:
                    return Sigmoid()
                if activation in ['tan', 'tanh', 'Tanh']:
        Severity: Minor
        Found in npdl/activations.py - About 2 hrs 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 __init__ has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(self, hidden_size=512, nb_seq=max_sent_size):
                print("Load parameters ...")
                params = Utils.load_params(hidden_size)
                print('Loading is done.')
        
        
        Severity: Major
        Found in applications/chatbot/model.py - About 2 hrs to fix

          Function get has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def get(objective):
              if objective.__class__.__name__ == 'str':
                  if objective in ['mse', 'MSE']:
                      return MSE()
                  if objective in ['mean_squared_error', 'MeanSquaredError']:
          Severity: Minor
          Found in npdl/objectives.py - About 2 hrs 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 get has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def get(optimizer):
              if optimizer.__class__.__name__ == 'str':
                  if optimizer in ['sgd', 'SGD']:
                      return SGD()
                  if optimizer in ['momentum', 'Momentum']:
          Severity: Minor
          Found in npdl/optimizers.py - About 2 hrs 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 backward has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def backward(self, pre_grad, dcn=None, dhn=None):
                  """Backward propagation.
                  
                  Parameters
                  ----------
          Severity: Minor
          Found in npdl/layers/recurrent.py - About 1 hr 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 forward has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def forward(self, input, *args, **kwargs):
          
                  self.last_input = input
          
                  # shape
          Severity: Minor
          Found in npdl/layers/convolution.py - About 1 hr 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 train has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def train(self, training_inputs, training_outputs):
                  self.feed_forward(training_inputs)
          
                  # 1. Output neuron deltas
                  pd_errors_wrt_output_neuron_total_net_input = [0] * len(self.output_layer.neurons)
          Severity: Minor
          Found in docs/tutorials/mlp_bp.py - About 1 hr 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 fit has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def fit(self, X, Y, max_iter=100, batch_size=64, shuffle=True,
          Severity: Major
          Found in npdl/model.py - About 1 hr to fix

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

                def __init__(self, n_out, n_in=None, nb_batch=None, nb_seq=None,
            Severity: Major
            Found in npdl/layers/recurrent.py - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language