【问题标题】:Incremental training of Topic Models in MALLETMALLET 中主题模型的增量训练
【发布时间】:2014-04-04 21:23:09
【问题描述】:

根据 MA​​LLET documentation,可以逐步训练主题模型:

"-output-model [FILENAME] 此选项指定要写入的文件 序列化的 MALLET 主题训练器对象。这种类型的输出是 适合暂停和重新开始训练”

我想在一组数据上训练主题,然后用另一组数据增加模型。在两个训练步骤之后,我想输出两个数据集的状态(使用 --output-state)。这是我尝试的方法:

# training on the first dataset
../mallet-2.0.7/bin/mallet import-dir --input input/ --keep-sequence --output input.mallet
../mallet-2.0.7/bin/mallet train-topics --input  input.mallet --num-topics 3 --output-state topic-state.gz --output-model model

# training on the second dataset
../mallet-2.0.7/bin/mallet import-dir --input input2/ --keep-sequence --output input2.mallet  --use-pipe-from input.mallet
../mallet-2.0.7/bin/mallet train-topics --input  input2.mallet --num-topics 3  --num-iterations 100 --output-state topic-state2.gz --input-model model

在最后一个命令中,如果我添加“--input-model model”,则来自第二个数据集的数据不会出现在输出状态文件中。如果我不添加它,则输出状态文件中不存在第一个数据集的数据。

如果我尝试在代码中向模型添加其他实例:

model.addInstances(instances);
model.setNumThreads(2);
model.setNumIterations(50);
model.estimate();

[...]

model.addInstances(instances2);
model.setNumThreads(2);
model.setNumIterations(50);
model.estimate();

我收到一个错误:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 30
    at cc.mallet.topics.ParallelTopicModel.buildInitialTypeTopicCounts(ParallelTopicModel.java:364)
    at cc.mallet.topics.ParallelTopicModel.addInstances(ParallelTopicModel.java:276)
    at cc.mallet.examples.TopicModel2.main(TopicModel2.java:66)

之前MALLET列表上也有类似问题:http://permalink.gmane.org/gmane.comp.ai.mallet.devel/924,http://permalink.gmane.org/gmane.comp.ai.mallet.devel/2139

那么主题模型的增量训练是否可行?

【问题讨论】:

  • 你知道这是否可能@vpekar?
  • 这有什么更新吗?

标签: topic-modeling mallet


【解决方案1】:

我认为你是这个对话线程的一部分,现在可能对你有用。

http://comments.gmane.org/gmane.comp.ai.mallet.devel/2153

【讨论】:

    猜你喜欢
    • 2016-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-20
    • 1970-01-01
    • 2012-09-25
    相关资源
    最近更新 更多