Class SequenceElement
- java.lang.Object
-
- org.deeplearning4j.models.sequencevectors.sequence.SequenceElement
-
- All Implemented Interfaces:
Serializable,Comparable<SequenceElement>
- Direct Known Subclasses:
ShallowSequenceElement,VocabWord
public abstract class SequenceElement extends Object implements Comparable<SequenceElement>, Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected shortcodeLengthprotected List<Byte>codesprotected org.nd4j.shade.guava.util.concurrent.AtomicDoubleelementFrequencyprotected intindexprotected booleaninitprotected booleanisLabelprotected booleanisLockedprotected List<Integer>pointsprotected AtomicLongsequencesCountprotected booleanspecialprotected LongstorageId
-
Constructor Summary
Constructors Constructor Description SequenceElement()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intcompareTo(SequenceElement o)booleanequals(Object object)Equals method override should be properly implemented for any extended class, otherwise it will be based on label equalityintgetCodeLength()Returns Huffman code length.List<Byte>getCodes()Returns Huffman tree codesdoublegetElementFrequency()This method returns SequenceElement's frequency in current training corpus.doublegetGradient(int index, double g, double lr)Deprecated.org.nd4j.linalg.api.ndarray.INDArraygetHistoricalGradient()Deprecated.intgetIndex()Returns index in Huffman treeabstract StringgetLabel()This method should return string representation of this SequenceElement, so it can be used forstatic longgetLongHash(@NonNull String string)List<Integer>getPoints()Returns Huffman tree pointslonggetSequencesCount()This method returns number of documents/sequences where this element was evidencedLonggetStorageId()inthashCode()hashCode method override should be properly implemented for any extended class, otherwise it will be based on label hashCodevoidincreaseElementFrequency(int by)Increases element frequency counter by argumentvoidincrementElementFrequency()Increases element frequency counter by 1voidincrementSequencesCount()Increments document count by onevoidincrementSequencesCount(long count)Increments document count by specified valuebooleanisLabel()Returns whether this element was defined as label, or nostatic org.nd4j.shade.jackson.databind.ObjectMappermapper()voidmarkAsLabel(boolean isLabel)This method specifies, whether this element should be treated as label for some sequence/document or not.voidsetCodeLength(short codeLength)This method fills codes and points up to codeLengthvoidsetCodes(List<Byte> codes)Sets Huffman tree codesvoidsetElementFrequency(long value)This method sets frequency value for this elementvoidsetHistoricalGradient(org.nd4j.linalg.api.ndarray.INDArray gradient)Deprecated.voidsetIndex(int index)Sets index in Huffman treevoidsetPoints(int[] points)Sets Huffman tree pointsvoidsetPoints(List<Integer> points)Sets Huffman tree pointsvoidsetSequencesCount(long count)This method sets documents count to specified valueabstract StringtoJSON()StringtoString()
-
-
-
Field Detail
-
elementFrequency
protected org.nd4j.shade.guava.util.concurrent.AtomicDouble elementFrequency
-
index
protected int index
-
codeLength
protected short codeLength
-
special
protected boolean special
-
isLabel
protected boolean isLabel
-
sequencesCount
protected AtomicLong sequencesCount
-
init
protected boolean init
-
storageId
protected Long storageId
-
isLocked
protected boolean isLocked
-
-
Method Detail
-
getLabel
public abstract String getLabel()
This method should return string representation of this SequenceElement, so it can be used for- Returns:
-
getSequencesCount
public long getSequencesCount()
This method returns number of documents/sequences where this element was evidenced- Returns:
-
setSequencesCount
public void setSequencesCount(long count)
This method sets documents count to specified value- Parameters:
count-
-
incrementSequencesCount
public void incrementSequencesCount()
Increments document count by one
-
incrementSequencesCount
public void incrementSequencesCount(long count)
Increments document count by specified value- Parameters:
count-
-
isLabel
public boolean isLabel()
Returns whether this element was defined as label, or no- Returns:
-
markAsLabel
public void markAsLabel(boolean isLabel)
This method specifies, whether this element should be treated as label for some sequence/document or not.- Parameters:
isLabel-
-
getElementFrequency
public double getElementFrequency()
This method returns SequenceElement's frequency in current training corpus.- Returns:
-
setElementFrequency
public void setElementFrequency(long value)
This method sets frequency value for this element- Parameters:
value-
-
incrementElementFrequency
public void incrementElementFrequency()
Increases element frequency counter by 1
-
increaseElementFrequency
public void increaseElementFrequency(int by)
Increases element frequency counter by argument- Parameters:
by-
-
equals
public boolean equals(Object object)
Equals method override should be properly implemented for any extended class, otherwise it will be based on label equality
-
getIndex
public int getIndex()
Returns index in Huffman tree- Returns:
- index >= 0, if tree was built, -1 otherwise
-
setIndex
public void setIndex(int index)
Sets index in Huffman tree- Parameters:
index-
-
setPoints
public void setPoints(List<Integer> points)
Sets Huffman tree points- Parameters:
points-
-
setPoints
public void setPoints(int[] points)
Sets Huffman tree points- Parameters:
points-
-
getCodeLength
public int getCodeLength()
Returns Huffman code length. Please note: maximum vocabulary/tree size depends on code length- Returns:
-
setCodeLength
public void setCodeLength(short codeLength)
This method fills codes and points up to codeLength- Parameters:
codeLength-
-
getLongHash
public static final long getLongHash(@NonNull @NonNull String string)
-
getGradient
@Deprecated public double getGradient(int index, double g, double lr)
Deprecated.Returns gradient for this specific element, at specific position- Parameters:
index-g-lr-- Returns:
-
setHistoricalGradient
@Deprecated public void setHistoricalGradient(org.nd4j.linalg.api.ndarray.INDArray gradient)
Deprecated.
-
getHistoricalGradient
@Deprecated public org.nd4j.linalg.api.ndarray.INDArray getHistoricalGradient()
Deprecated.
-
hashCode
public int hashCode()
hashCode method override should be properly implemented for any extended class, otherwise it will be based on label hashCode
-
compareTo
public int compareTo(SequenceElement o)
- Specified by:
compareToin interfaceComparable<SequenceElement>
-
toJSON
public abstract String toJSON()
- Returns:
-
getStorageId
public Long getStorageId()
-
mapper
public static org.nd4j.shade.jackson.databind.ObjectMapper mapper()
-
-