use of org.deeplearning4j.plot.BarnesHutTsne in project deeplearning4j by deeplearning4j.
the class ApiTest method testUpdateCoords.
@Test
@Ignore
public void testUpdateCoords() throws Exception {
Nd4j.ENFORCE_NUMERICAL_STABILITY = true;
Nd4j.factory().setDType(DataBuffer.Type.DOUBLE);
Nd4j.getRandom().setSeed(123);
BarnesHutTsne b = new BarnesHutTsne.Builder().stopLyingIteration(250).theta(0.5).learningRate(500).useAdaGrad(false).numDimension(2).build();
ClassPathResource resource = new ClassPathResource("/mnist2500_X.txt");
File f = resource.getFile();
INDArray data = Nd4j.readNumpy(f.getAbsolutePath(), " ").get(NDArrayIndex.interval(0, 100), NDArrayIndex.interval(0, 784));
ClassPathResource labels = new ClassPathResource("mnist2500_labels.txt");
List<String> labelsList = IOUtils.readLines(labels.getInputStream()).subList(0, 100);
b.fit(data);
b.saveAsFile(labelsList, "coords.csv");
throw new RuntimeException("Not implemented");
}
use of org.deeplearning4j.plot.BarnesHutTsne in project deeplearning4j by deeplearning4j.
the class UITest method testPosting.
@Test
public void testPosting() throws Exception {
// File inputFile = new ClassPathResource("/big/raw_sentences.txt").getFile();
File inputFile = new ClassPathResource("/basic/word2vec_advance.txt").getFile();
SentenceIterator iter = UimaSentenceIterator.createWithPath(inputFile.getAbsolutePath());
// Split on white spaces in the line to get words
TokenizerFactory t = new DefaultTokenizerFactory();
t.setTokenPreProcessor(new CommonPreprocessor());
Word2Vec vec = new Word2Vec.Builder().minWordFrequency(1).iterations(1).epochs(1).layerSize(20).stopWords(new ArrayList<String>()).useAdaGrad(false).negativeSample(5).seed(42).windowSize(5).iterate(iter).tokenizerFactory(t).build();
vec.fit();
File tempFile = File.createTempFile("temp", "w2v");
tempFile.deleteOnExit();
WordVectorSerializer.writeWordVectors(vec, tempFile);
WordVectors vectors = WordVectorSerializer.loadTxtVectors(tempFile);
//Initialize
UIServer.getInstance();
UiConnectionInfo uiConnectionInfo = new UiConnectionInfo.Builder().setAddress("localhost").setPort(9000).build();
BarnesHutTsne tsne = new BarnesHutTsne.Builder().normalize(false).setFinalMomentum(0.8f).numDimension(2).setMaxIter(10).build();
vectors.lookupTable().plotVocab(tsne, vectors.lookupTable().getVocabCache().numWords(), uiConnectionInfo);
Thread.sleep(100000);
}
use of org.deeplearning4j.plot.BarnesHutTsne in project deeplearning4j by deeplearning4j.
the class InMemoryLookupTable method plotVocab.
/**
* Render the words via tsne
*/
@Override
public void plotVocab(int numWords, File file) {
BarnesHutTsne tsne = new BarnesHutTsne.Builder().normalize(false).setFinalMomentum(0.8f).numDimension(2).setMaxIter(1000).build();
plotVocab(tsne, numWords, file);
}
use of org.deeplearning4j.plot.BarnesHutTsne in project deeplearning4j by deeplearning4j.
the class InMemoryLookupTable method plotVocab.
/**
* Render the words via tsne
*/
@Override
public void plotVocab(int numWords, UiConnectionInfo connectionInfo) {
BarnesHutTsne tsne = new BarnesHutTsne.Builder().normalize(false).setFinalMomentum(0.8f).numDimension(2).setMaxIter(1000).build();
plotVocab(tsne, numWords, connectionInfo);
}
Aggregations