class_docstr: K is to mark Kashgari version of CRF
  Conditional Random Field layer (tf.keras)
  `CRF` can be used as the last layer in a network (as a classifier). Input shape (features)
  must be equal to the number of classes the CRF can predict (a linear layer is recommended).
  
  Args:
      num_labels (int): the number of labels to tag each temporal input.
  
  Input shape:
      nD tensor with shape `(batch_size, sentence length, num_classes)`.
  
  Output shape:
      nD tensor with shape: `(batch_size, sentence length, num_classes)`.
  
  Masking
      This layer supports keras masking for input data with a variable number
      of timesteps. To introduce masks to your data,
      use an embedding layer with the `mask_zero` parameter
      set to `True` or add a Masking Layer before this Layer
class_docstr_tok: ["K","is","to","mark","Kashgari","version","of","CRF","Conditional","Random","Field","layer","(","tf.keras",")","`","CRF","`","can","be","used","as","the","last","layer","in","a","network","(","as","a","classifier",")",".","Input","shape","(","features",")","must","be","equal","to","the","number","of","classes","the","CRF","can","predict","(","a","linear","layer","is","recommended",")",".","Args",":","num_labels","(","int",")",":","the","number","of","labels","to","tag","each","temporal","input",".","Input","shape",":","nD","tensor","with","shape","`","(","batch_size",",","sentence","length",",","num_classes",")","`",".","Output","shape",":","nD","tensor","with","shape",":","`","(","batch_size",",","sentence","length",",","num_classes",")","`",".","Masking","This","layer","supports","keras","masking","for","input","data","with","a","variable","number","of","timesteps",".","To","introduce","masks","to","your","data",",","use","an","embedding","layer","with","the","`","mask_zero","`","parameter","set","to","`","True","`","or","add","a","Masking","Layer","before","this","Layer"]
code: def __init__(self, sparse_target=True, **kwargs):
      if LooseVersion(tf.__version__) < "2.2.0":
          raise ImportError(
              "The KConditionalRandomField requires TensorFlow 2.2.x version or higher."
          )
  
      super().__init__()
      self.transitions = kwargs.pop("transitions", None)
      self.output_dim = kwargs.pop("output_dim", None)
      self.sparse_target = sparse_target
      self.sequence_lengths = None
      self.mask = None
  
file_path: Kashgari/kashgari/layers/conditional_random_field.py
imports: from distutils.version import LooseVersion
  import tensorflow
  import tensorflow.keras.backend
  import tensorflow_addons
label_desc: Use image node_id 1 to create a new KConditionalRandomField object from inherited base classes: tf.keras.layers with example: obj = KConditionalRandomField(sparse_target)