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 short
codeLength
protected List<Byte>
codes
protected org.nd4j.shade.guava.util.concurrent.AtomicDouble
elementFrequency
protected int
index
protected boolean
init
protected boolean
isLabel
protected boolean
isLocked
protected List<Integer>
points
protected AtomicLong
sequencesCount
protected boolean
special
protected Long
storageId
-
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 int
compareTo(SequenceElement o)
boolean
equals(Object object)
Equals method override should be properly implemented for any extended class, otherwise it will be based on label equalityint
getCodeLength()
Returns Huffman code length.List<Byte>
getCodes()
Returns Huffman tree codesdouble
getElementFrequency()
This method returns SequenceElement's frequency in current training corpus.double
getGradient(int index, double g, double lr)
Deprecated.org.nd4j.linalg.api.ndarray.INDArray
getHistoricalGradient()
Deprecated.int
getIndex()
Returns index in Huffman treeabstract String
getLabel()
This method should return string representation of this SequenceElement, so it can be used forstatic long
getLongHash(@NonNull String string)
List<Integer>
getPoints()
Returns Huffman tree pointslong
getSequencesCount()
This method returns number of documents/sequences where this element was evidencedLong
getStorageId()
int
hashCode()
hashCode method override should be properly implemented for any extended class, otherwise it will be based on label hashCodevoid
increaseElementFrequency(int by)
Increases element frequency counter by argumentvoid
incrementElementFrequency()
Increases element frequency counter by 1void
incrementSequencesCount()
Increments document count by onevoid
incrementSequencesCount(long count)
Increments document count by specified valueboolean
isLabel()
Returns whether this element was defined as label, or nostatic org.nd4j.shade.jackson.databind.ObjectMapper
mapper()
void
markAsLabel(boolean isLabel)
This method specifies, whether this element should be treated as label for some sequence/document or not.void
setCodeLength(short codeLength)
This method fills codes and points up to codeLengthvoid
setCodes(List<Byte> codes)
Sets Huffman tree codesvoid
setElementFrequency(long value)
This method sets frequency value for this elementvoid
setHistoricalGradient(org.nd4j.linalg.api.ndarray.INDArray gradient)
Deprecated.void
setIndex(int index)
Sets index in Huffman treevoid
setPoints(int[] points)
Sets Huffman tree pointsvoid
setPoints(List<Integer> points)
Sets Huffman tree pointsvoid
setSequencesCount(long count)
This method sets documents count to specified valueabstract String
toJSON()
String
toString()
-
-
-
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:
compareTo
in interfaceComparable<SequenceElement>
-
toJSON
public abstract String toJSON()
- Returns:
-
getStorageId
public Long getStorageId()
-
mapper
public static org.nd4j.shade.jackson.databind.ObjectMapper mapper()
-
-