public static void main(String args[]) throws IOException { ServerSocket server; try{ server = new ServerSocket(5559); System.out.println("Listening for connection on port 5559 ...."); while (true) { Socket clientSocket = server.accept(); new Thread(new WorkerRunnable(clientSocket)).start(); } }catch (IOException e) { System.out.println("Could not listen on port: 4001"); } }
(LabelSequence) data.get(doc).topicSequence; sampleTopicsForOneDoc (tokenSequence, topicSequence, true); buildLocalTypeTopicCounts();
public void temperAlpha(WorkerRunnable[] runnables) { // First clear the sufficient statistic histograms Arrays.fill(docLengthCounts, 0); for (int topic = 0; topic < topicDocCounts.length; topic++) { Arrays.fill(topicDocCounts[topic], 0); } for (int thread = 0; thread < numThreads; thread++) { int[] sourceLengthCounts = runnables[thread].getDocLengthCounts(); int[][] sourceTopicCounts = runnables[thread].getTopicDocCounts(); for (int count=0; count < sourceLengthCounts.length; count++) { if (sourceLengthCounts[count] > 0) { sourceLengthCounts[count] = 0; } } for (int topic=0; topic < numTopics; topic++) { for (int count=0; count < sourceTopicCounts[topic].length; count++) { if (sourceTopicCounts[topic][count] > 0) { sourceTopicCounts[topic][count] = 0; } } } } for (int topic = 0; topic < numTopics; topic++) { alpha[topic] = 1.0; } alphaSum = numTopics; }
int[] sourceTotals = runnables[thread].getTokensPerTopic(); for (int topic = 0; topic < numTopics; topic++) { tokensPerTopic[topic] += sourceTotals[topic]; runnables[thread].getTypeTopicCounts();
runnables[thread] = new WorkerRunnable(numTopics, alpha, alphaSum, beta, random, data, runnables[thread].initializeAlphaStatistics(docLengthCounts.length); runnables[0] = new WorkerRunnable(numTopics, alpha, alphaSum, beta, random, data, runnables[0].initializeAlphaStatistics(docLengthCounts.length); runnables[0].makeOnlyThread(); if (iteration > burninPeriod && optimizeInterval != 0 && iteration % saveSampleInterval == 0) { runnables[thread].collectAlphaStatistics(); int[] runnableTotals = runnables[thread].getTokensPerTopic(); System.arraycopy(tokensPerTopic, 0, runnableTotals, 0, numTopics); int[][] runnableCounts = runnables[thread].getTypeTopicCounts(); for (int type = 0; type < numTypes; type++) { int[] targetCounts = runnableCounts[type]; if (iteration > burninPeriod && optimizeInterval != 0 && iteration % saveSampleInterval == 0) { runnables[0].collectAlphaStatistics();
runnables[thread].resetBeta(beta, betaSum);
runnables[thread] = new WorkerRunnable(numTopics, alpha, alphaSum, beta, random, data, runnables[thread].initializeAlphaStatistics(docLengthCounts.length); runnables[0] = new WorkerRunnable(numTopics, alpha, alphaSum, beta, random, data, runnables[0].initializeAlphaStatistics(docLengthCounts.length); runnables[0].makeOnlyThread(); if (iteration > burninPeriod && optimizeInterval != 0 && iteration % saveSampleInterval == 0) { runnables[thread].collectAlphaStatistics(); int[] runnableTotals = runnables[thread].getTokensPerTopic(); System.arraycopy(tokensPerTopic, 0, runnableTotals, 0, numTopics); int[][] runnableCounts = runnables[thread].getTypeTopicCounts(); for (int type = 0; type < numTypes; type++) { int[] targetCounts = runnableCounts[type]; if (iteration > burninPeriod && optimizeInterval != 0 && iteration % saveSampleInterval == 0) { runnables[0].collectAlphaStatistics();
int[] sourceTotals = runnables[thread].getTokensPerTopic(); for (int topic = 0; topic < numTopics; topic++) { tokensPerTopic[topic] += sourceTotals[topic]; runnables[thread].getTypeTopicCounts();
runnables[thread].resetBeta(beta, betaSum);
runnables[thread] = new WorkerRunnable(numTopics, alpha, alphaSum, beta, random, data, runnables[thread].initializeAlphaStatistics(docLengthCounts.length); runnables[0] = new WorkerRunnable(numTopics, alpha, alphaSum, beta, random, data, runnables[0].initializeAlphaStatistics(docLengthCounts.length); runnables[0].makeOnlyThread(); if (iteration > burninPeriod && optimizeInterval != 0 && iteration % saveSampleInterval == 0) { runnables[thread].collectAlphaStatistics(); int[] runnableTotals = runnables[thread].getTokensPerTopic(); System.arraycopy(tokensPerTopic, 0, runnableTotals, 0, numTopics); int[][] runnableCounts = runnables[thread].getTypeTopicCounts(); for (int type = 0; type < numTypes; type++) { int[] targetCounts = runnableCounts[type]; if (iteration > burninPeriod && optimizeInterval != 0 && iteration % saveSampleInterval == 0) { runnables[0].collectAlphaStatistics();
public void temperAlpha(WorkerRunnable[] runnables) { // First clear the sufficient statistic histograms Arrays.fill(docLengthCounts, 0); for (int topic = 0; topic < topicDocCounts.length; topic++) { Arrays.fill(topicDocCounts[topic], 0); } for (int thread = 0; thread < numThreads; thread++) { int[] sourceLengthCounts = runnables[thread].getDocLengthCounts(); int[][] sourceTopicCounts = runnables[thread].getTopicDocCounts(); for (int count=0; count < sourceLengthCounts.length; count++) { if (sourceLengthCounts[count] > 0) { sourceLengthCounts[count] = 0; } } for (int topic=0; topic < numTopics; topic++) { for (int count=0; count < sourceTopicCounts[topic].length; count++) { if (sourceTopicCounts[topic][count] > 0) { sourceTopicCounts[topic][count] = 0; } } } } for (int topic = 0; topic < numTopics; topic++) { alpha[topic] = 1.0; } alphaSum = numTopics; }
(LabelSequence) data.get(doc).topicSequence; sampleTopicsForOneDoc (tokenSequence, topicSequence, true); buildLocalTypeTopicCounts();
int[] sourceTotals = runnables[thread].getTokensPerTopic(); for (int topic = 0; topic < numTopics; topic++) { tokensPerTopic[topic] += sourceTotals[topic]; runnables[thread].getTypeTopicCounts();
new WorkerRunnable( clientSocket, "Multithreaded Server")).start();
runnables[thread].resetBeta(beta, betaSum);
public void temperAlpha(WorkerRunnable[] runnables) { // First clear the sufficient statistic histograms Arrays.fill(docLengthCounts, 0); for (int topic = 0; topic < topicDocCounts.length; topic++) { Arrays.fill(topicDocCounts[topic], 0); } for (int thread = 0; thread < numThreads; thread++) { int[] sourceLengthCounts = runnables[thread].getDocLengthCounts(); int[][] sourceTopicCounts = runnables[thread].getTopicDocCounts(); for (int count=0; count < sourceLengthCounts.length; count++) { if (sourceLengthCounts[count] > 0) { sourceLengthCounts[count] = 0; } } for (int topic=0; topic < numTopics; topic++) { for (int count=0; count < sourceTopicCounts[topic].length; count++) { if (sourceTopicCounts[topic][count] > 0) { sourceTopicCounts[topic][count] = 0; } } } } for (int topic = 0; topic < numTopics; topic++) { alpha[topic] = 1.0; } alphaSum = numTopics; }
(LabelSequence) data.get(doc).topicSequence; sampleTopicsForOneDoc (tokenSequence, topicSequence, true); buildLocalTypeTopicCounts();
int[] sourceLengthCounts = runnables[thread].getDocLengthCounts(); int[][] sourceTopicCounts = runnables[thread].getTopicDocCounts();
int[] sourceLengthCounts = runnables[thread].getDocLengthCounts(); int[][] sourceTopicCounts = runnables[thread].getTopicDocCounts();
int[] sourceLengthCounts = runnables[thread].getDocLengthCounts(); int[][] sourceTopicCounts = runnables[thread].getTopicDocCounts();