Class WorkerCallable

  • All Implemented Interfaces:
    java.util.concurrent.Callable<java.lang.Integer>
    Direct Known Subclasses:
    DMRCallable

    public class WorkerCallable
    extends java.lang.Object
    implements java.util.concurrent.Callable<java.lang.Integer>
    A parallel topic model callable task. This class replaces the WorkerRunnable class.
    Author:
    David Mimno, Andrew McCallum
    • Field Detail

      • numTopics

        protected int numTopics
      • topicMask

        protected int topicMask
      • topicBits

        protected int topicBits
      • numTypes

        protected int numTypes
      • alpha

        protected double[] alpha
      • alphaSum

        protected double alphaSum
      • beta

        protected double beta
      • betaSum

        protected double betaSum
      • smoothingOnlyMass

        protected double smoothingOnlyMass
      • cachedCoefficients

        protected double[] cachedCoefficients
      • typeTopicCounts

        protected int[][] typeTopicCounts
      • tokensPerTopic

        protected int[] tokensPerTopic
      • docLengthCounts

        protected int[] docLengthCounts
      • topicDocCounts

        protected int[][] topicDocCounts
    • Constructor Detail

      • WorkerCallable

        public WorkerCallable()
      • WorkerCallable

        public WorkerCallable​(int numTopics,
                              double[] alpha,
                              double alphaSum,
                              double beta,
                              Randoms random,
                              java.util.ArrayList<TopicAssignment> data,
                              int[][] typeTopicCounts,
                              int[] tokensPerTopic,
                              int startDoc,
                              int numDocs)
    • Method Detail

      • makeOnlyThread

        public void makeOnlyThread()
        If there is only one thread, we don't need to go through communication overhead. This method asks this worker not to prepare local type-topic counts. The method should be called when we are using this code in a non-threaded environment.
      • getTokensPerTopic

        public int[] getTokensPerTopic()
      • getTypeTopicCounts

        public int[][] getTypeTopicCounts()
      • getDocLengthCounts

        public int[] getDocLengthCounts()
      • getTopicDocCounts

        public int[][] getTopicDocCounts()
      • initializeAlphaStatistics

        public void initializeAlphaStatistics​(int size)
      • collectAlphaStatistics

        public void collectAlphaStatistics()
      • resetBeta

        public void resetBeta​(double beta,
                              double betaSum)
      • buildLocalTypeTopicCounts

        public void buildLocalTypeTopicCounts()
        Once we have sampled the local counts, trash the "global" type topic counts and reuse the space to build a summary of the type topic counts specific to this worker's section of the corpus.
      • call

        public java.lang.Integer call()
                               throws java.lang.Exception
        Specified by:
        call in interface java.util.concurrent.Callable<java.lang.Integer>
        Throws:
        java.lang.Exception
      • sampleTopicsForOneDoc

        protected int sampleTopicsForOneDoc​(FeatureSequence tokenSequence,
                                            FeatureSequence topicSequence,
                                            boolean readjustTopicsAndStats)