-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from sashafrey/master
Improved reporting of errors and exceptions
- Loading branch information
Showing
12 changed files
with
90 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This example demonstrates various ways of retrieving Phi matrix from BigARTM | ||
# -*- coding: utf-8 -*- | ||
import glob | ||
|
||
import artm.messages_pb2 | ||
import artm.library | ||
|
||
# Create master component and infer topic model | ||
batches_disk_path = 'kos' | ||
with artm.library.MasterComponent(disk_path=batches_disk_path) as master: | ||
topic_names = [] | ||
for topic_index in range(0, 10): | ||
topic_names.append("Topic" + str(topic_index)) | ||
model = master.CreateModel(topic_names=topic_names) | ||
|
||
for iteration in range(0, 2): | ||
master.InvokeIteration() | ||
master.WaitIdle() # wait for all batches are processed | ||
model.Synchronize() # synchronize model | ||
|
||
# The following code retrieves one topic at a time. | ||
# This avoids retrieving large topic models in a single protobuf message. | ||
print "Output p(w|t) values for the first few tokens (alphabetically) in each topic:" | ||
for topic_name in topic_names: | ||
args = artm.messages_pb2.GetTopicModelArgs() | ||
args.model_name = model.name() | ||
args.topic_name.append(topic_name) | ||
topic_model = master.GetTopicModel(args=args) # represents one column in Phi matrix | ||
print topic_model.topic_name[0], | ||
for i in range(0, 5): | ||
print topic_model.token[i], "%.5f" % topic_model.token_weights[i].value[0], | ||
print "..." |