rasa/utils/tensorflow/layers.py
File layers.py
has 1226 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import logging
from typing import List, Optional, Text, Tuple, Callable, Union, Any
import tensorflow as tf
# TODO: The following is not (yet) available via tf.keras
Function __init__
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function _loss_sigmoid
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _loss_sigmoid(
Function _train_sim
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _train_sim(
Function _accuracy
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _accuracy(
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function call
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def call(
Function call
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def call(
Function _loss_cross_entropy
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _loss_cross_entropy(
Function _loss_margin
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _loss_margin(
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function _sample_candidates
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _sample_candidates(
Function _sample_negatives
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _sample_negatives(
Function _compute_softmax_loss
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _compute_softmax_loss(
Function _train_sim
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _train_sim(
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function _compute_sigmoid_loss
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _compute_sigmoid_loss(
Function apply_mask_and_scaling
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def apply_mask_and_scaling(
self, loss: tf.Tensor, mask: Optional[tf.Tensor]
) -> tf.Tensor:
"""Scales the loss and applies the mask if necessary.
- 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"