Showing 63 of 162 total issues
Function forward
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def forward(self, input, mask, c0=None, h0=None):
assert np.ndim(input) == 3, 'Only support batch training.'
# record
self.last_input = input
- Read upRead up
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 9 (exceeds 5 allowed). Consider refactoring. Open
def forward(self, input, c0=None, h0=None):
"""Forward propagation.
Parameters
----------
- Read upRead up
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 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, embed_words=None, static=None,
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, num_inputs, num_hidden, num_outputs,
Avoid deeply nested control flow statements. Open
for w in np.arange(new_w):
outputs[a, b, h, w] = np.mean(input[a, b, h:h + pool_h, w:w + pool_w])
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, nb_filter, filter_size, input_shape=None, stride=1,
Avoid deeply nested control flow statements. Open
for h in np.arange(new_img_h):
for w in np.arange(new_img_w):
h_shift, w_shift = h * self.stride, w * self.stride
layer_grads[b, t, h_shift:h_shift + filter_h, w_shift:w_shift + filter_w] += \
self.W[r, t] * delta[b, r, h, w]
Avoid deeply nested control flow statements. Open
for w in np.arange(new_w):
patch = self.last_input[a, b, h:h + pool_h, w:w + pool_w]
max_idx = np.unravel_index(patch.argmax(), patch.shape)
h_shift, w_shift = h * pool_h + max_idx[0], w * pool_w + max_idx[1]
layer_grads[a, b, h_shift, w_shift] = pre_grad[a, b, a, w]
Avoid deeply nested control flow statements. Open
for w in np.arange(new_w):
h_shift, w_shift = h * pool_h, w * pool_w
layer_grads[a, b, h_shift: h_shift + pool_h, w_shift: w_shift + pool_w] = \
pre_grad[a, b, h, w] / length
Function forward
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def forward(self, idxs, masks):
##############################
# Encode
##############################
- Read upRead up
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
for w in np.arange(new_w):
outputs[a, b, h, w] = np.max(input[a, b, h:h + pool_h, w:w + pool_w])
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, beta1=0.9, beta2=0.999, epsilon=1e-8, *args, **kwargs):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, lr=0.001, clip=-1, decay=0., lr_min=0., lr_max=np.inf):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, epsilon=1e-6, momentum=0.9, axis=0,
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, beta1=0.9, beta2=0.999, epsilon=1e-8, *args, **kwargs):
Function init_weights_from_hidden_layer_neurons_to_output_layer_neurons
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def init_weights_from_hidden_layer_neurons_to_output_layer_neurons(self, output_layer_weights):
weight_num = 0
for o in range(len(self.output_layer.neurons)):
for h in range(len(self.hidden_layer.neurons)):
if not output_layer_weights:
- Read upRead up
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_weights_from_inputs_to_hidden_layer_neurons
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def init_weights_from_inputs_to_hidden_layer_neurons(self, hidden_layer_weights):
weight_num = 0
for h in range(len(self.hidden_layer.neurons)):
for i in range(self.num_inputs):
if not hidden_layer_weights:
- Read upRead up
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 too many return
statements within this function. Open
return copy.deepcopy(activation)
Avoid too many return
statements within this function. Open
return LecunUniform()
Avoid too many return
statements within this function. Open
return copy.deepcopy(optimizer)