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 doublegetGradient(int column, double gradient)Returns gradient for specified wordLonggetTableId()Returns unique ID of this table.VocabCache<T>getVocabCache()Returns corresponding vocabularyorg.nd4j.linalg.api.ndarray.INDArraygetWeights()voiditerate(T w1, T w2)Deprecated.voiditerateSample(T w1, T w2, AtomicLong nextRandom, double alpha)Deprecated.intlayerSize()The layer size for the lookup tableorg.nd4j.linalg.api.ndarray.INDArrayloadCodes(int[] codes)Loads the co-occurrences for the given codesvoidputCode(int codeIndex, org.nd4j.linalg.api.ndarray.INDArray code)voidputVector(String word, org.nd4j.linalg.api.ndarray.INDArray vector)Inserts a word vectorvoidresetWeights()Reset the weights of the cachevoidresetWeights(boolean reset)Clear out all weights regardlessvoidsetLearningRate(double lr)Sets the learning ratevoidsetTableId(Long tableId)Set's table Id.org.nd4j.linalg.api.ndarray.INDArrayvector(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
-
-