public class CBOW<T extends SequenceElement> extends java.lang.Object implements ElementsLearningAlgorithm<T>
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.ThreadLocal<java.util.List<org.nd4j.linalg.api.ops.aggregates.Aggregate>> |
batches |
protected org.nd4j.linalg.util.DeviceLocalNDArray |
expTable |
protected static double |
MAX_EXP |
protected double |
negative |
protected double |
sampling |
protected org.nd4j.linalg.util.DeviceLocalNDArray |
syn0 |
protected org.nd4j.linalg.util.DeviceLocalNDArray |
syn1 |
protected org.nd4j.linalg.util.DeviceLocalNDArray |
syn1Neg |
protected org.nd4j.linalg.util.DeviceLocalNDArray |
table |
protected boolean |
useAdaGrad |
protected int[] |
variableWindows |
protected int |
window |
| Constructor and Description |
|---|
CBOW() |
| Modifier and Type | Method and Description |
|---|---|
Sequence<T> |
applySubsampling(Sequence<T> sequence,
java.util.concurrent.atomic.AtomicLong nextRandom) |
void |
cbow(int i,
java.util.List<T> sentence,
int b,
java.util.concurrent.atomic.AtomicLong nextRandom,
double alpha,
int currentWindow) |
void |
configure(VocabCache<T> vocabCache,
WeightLookupTable<T> lookupTable,
VectorsConfiguration configuration) |
void |
finish() |
java.util.List<org.nd4j.linalg.api.ops.aggregates.Aggregate> |
getBatch() |
java.lang.String |
getCodeName() |
boolean |
isEarlyTerminationHit() |
void |
iterateSample(T currentWord,
int[] windowWords,
java.util.concurrent.atomic.AtomicLong nextRandom,
double alpha,
boolean isInference,
int numLabels,
boolean trainWords,
org.nd4j.linalg.api.ndarray.INDArray inferenceVector) |
double |
learnSequence(Sequence<T> sequence,
java.util.concurrent.atomic.AtomicLong nextRandom,
double learningRate)
This method does training over the sequence of elements passed into it
|
void |
pretrain(SequenceIterator<T> iterator)
CBOW doesn't involve any pretraining
|
protected static double MAX_EXP
protected int window
protected boolean useAdaGrad
protected double negative
protected double sampling
protected int[] variableWindows
protected org.nd4j.linalg.util.DeviceLocalNDArray syn0
protected org.nd4j.linalg.util.DeviceLocalNDArray syn1
protected org.nd4j.linalg.util.DeviceLocalNDArray syn1Neg
protected org.nd4j.linalg.util.DeviceLocalNDArray expTable
protected org.nd4j.linalg.util.DeviceLocalNDArray table
protected java.lang.ThreadLocal<java.util.List<org.nd4j.linalg.api.ops.aggregates.Aggregate>> batches
public java.util.List<org.nd4j.linalg.api.ops.aggregates.Aggregate> getBatch()
public java.lang.String getCodeName()
getCodeName in interface ElementsLearningAlgorithm<T extends SequenceElement>public void configure(@NonNull
VocabCache<T> vocabCache,
@NonNull
WeightLookupTable<T> lookupTable,
@NonNull
VectorsConfiguration configuration)
configure in interface ElementsLearningAlgorithm<T extends SequenceElement>public void pretrain(SequenceIterator<T> iterator)
pretrain in interface ElementsLearningAlgorithm<T extends SequenceElement>iterator - public void finish()
finish in interface ElementsLearningAlgorithm<T extends SequenceElement>public double learnSequence(Sequence<T> sequence, java.util.concurrent.atomic.AtomicLong nextRandom, double learningRate)
ElementsLearningAlgorithmlearnSequence in interface ElementsLearningAlgorithm<T extends SequenceElement>public boolean isEarlyTerminationHit()
isEarlyTerminationHit in interface ElementsLearningAlgorithm<T extends SequenceElement>public void iterateSample(T currentWord, int[] windowWords, java.util.concurrent.atomic.AtomicLong nextRandom, double alpha, boolean isInference, int numLabels, boolean trainWords, org.nd4j.linalg.api.ndarray.INDArray inferenceVector)
public void cbow(int i,
java.util.List<T> sentence,
int b,
java.util.concurrent.atomic.AtomicLong nextRandom,
double alpha,
int currentWindow)