ETM icon indicating copy to clipboard operation
ETM copied to clipboard

Example Code for Use

Open dubbsbrandon opened this issue 5 years ago • 7 comments

I'm having some trouble figuring out the appropriate input and output for the model after it is created. Is there any example you can provide for the use and what I can expect to have returned? As I understand it, it should return the predicted topics, with the embedding of the document being passed, correct?

dubbsbrandon avatar Oct 10 '19 15:10 dubbsbrandon

Agreed, it's opaque how to use this for new documents after training, which went great. Any chance of some more insight into how to apply it?

arnicas avatar Dec 12 '19 16:12 arnicas

Same question !

duongkstn avatar Feb 19 '20 02:02 duongkstn

That would be Very helpful, I hope you can provide us with such functions

kingomalek avatar Apr 02 '20 10:04 kingomalek

Same question

yilunzhao avatar Apr 21 '20 08:04 yilunzhao

any update ? I have the same question

Shiro-LK avatar Jul 08 '20 16:07 Shiro-LK

Same question!

460176980 avatar Jul 20 '20 01:07 460176980

I am on the same issue - there are various places where you can get a return value which is the size of your topics, which is what you want, from looking at the eval script I have this:

NUM_TOPICS = 128

def predict(normd_bow):
    thetaAvg = torch.zeros(1, NUM_TOPICS)
    sums = normd_bow.sum(1).unsqueeze(1)
    thetaWeightedAvg = torch.zeros(1, NUM_TOPICS)
    theta, _ = model.get_theta(normd_bow)
    thetaAvg += theta.sum(0).unsqueeze(0) / normd_bow.shape[0]
    weighed_theta = sums * theta
    thetaWeightedAvg += weighed_theta.sum(0).unsqueeze(0)
    return thetaWeightedAvg

Created from this code.

EDIT: I have no idea if this is correct!

ydennisy avatar Oct 09 '20 17:10 ydennisy