Interface WeightLookupTable<T extends SequenceElement>
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
InMemoryLookupTable
public interface WeightLookupTable<T extends SequenceElement> extends Serializable
General weight lookup table- Author:
- Adam Gibson
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description double
getGradient(int column, double gradient)
Returns gradient for specified wordLong
getTableId()
Returns unique ID of this table.VocabCache<T>
getVocabCache()
Returns corresponding vocabularyorg.nd4j.linalg.api.ndarray.INDArray
getWeights()
void
iterate(T w1, T w2)
Deprecated.void
iterateSample(T w1, T w2, AtomicLong nextRandom, double alpha)
Deprecated.int
layerSize()
The layer size for the lookup tableorg.nd4j.linalg.api.ndarray.INDArray
loadCodes(int[] codes)
Loads the co-occurrences for the given codesvoid
putCode(int codeIndex, org.nd4j.linalg.api.ndarray.INDArray code)
void
putVector(String word, org.nd4j.linalg.api.ndarray.INDArray vector)
Inserts a word vectorvoid
resetWeights()
Reset the weights of the cachevoid
resetWeights(boolean reset)
Clear out all weights regardlessvoid
setLearningRate(double lr)
Sets the learning ratevoid
setTableId(Long tableId)
Set's table Id.org.nd4j.linalg.api.ndarray.INDArray
vector(String word)
Iterator<org.nd4j.linalg.api.ndarray.INDArray>
vectors()
Iterates through all of the vectors in the cache
-
-
-
Method Detail
-
getTableId
Long getTableId()
Returns unique ID of this table. Used for JointStorage/DistributedLookupTable mechanics- Returns:
- ID of this table
-
setTableId
void setTableId(Long tableId)
Set's table Id. Please note, it should be unique withing Joint/Distributed LookupTable- Parameters:
tableId
-
-
layerSize
int layerSize()
The layer size for the lookup table- Returns:
- the layer size for the lookup table
-
getGradient
double getGradient(int column, double gradient)
Returns gradient for specified word- Parameters:
column
-gradient
-- Returns:
-
resetWeights
void resetWeights(boolean reset)
Clear out all weights regardless- Parameters:
reset
-
-
putCode
void putCode(int codeIndex, org.nd4j.linalg.api.ndarray.INDArray code)
- Parameters:
codeIndex
-code
-
-
loadCodes
org.nd4j.linalg.api.ndarray.INDArray loadCodes(int[] codes)
Loads the co-occurrences for the given codes- Parameters:
codes
- the codes to load- Returns:
- an ndarray of code.length by layerSize
-
iterate
@Deprecated void iterate(T w1, T w2)
Deprecated.Iterate on the given 2 vocab words- Parameters:
w1
- the first word to iterate onw2
- the second word to iterate on
-
iterateSample
@Deprecated void iterateSample(T w1, T w2, AtomicLong nextRandom, double alpha)
Deprecated.Iterate on the given 2 vocab words- Parameters:
w1
- the first word to iterate onw2
- the second word to iterate onnextRandom
- nextRandom for samplingalpha
- the alpha to use for learning
-
putVector
void putVector(String word, org.nd4j.linalg.api.ndarray.INDArray vector)
Inserts a word vector- Parameters:
word
- the word to insertvector
- the vector to insert
-
vector
org.nd4j.linalg.api.ndarray.INDArray vector(String word)
- Parameters:
word
-- Returns:
-
resetWeights
void resetWeights()
Reset the weights of the cache
-
setLearningRate
void setLearningRate(double lr)
Sets the learning rate- Parameters:
lr
-
-
vectors
Iterator<org.nd4j.linalg.api.ndarray.INDArray> vectors()
Iterates through all of the vectors in the cache- Returns:
- an iterator for all vectors in the cache
-
getWeights
org.nd4j.linalg.api.ndarray.INDArray getWeights()
-
getVocabCache
VocabCache<T> getVocabCache()
Returns corresponding vocabulary
-
-