Skip to content

Conversation

@wangmiao1981
Copy link
Contributor

What changes were proposed in this pull request?

While adding DistributedLDAModel training summary for SparkR, I found that the logPrior for original and loaded model is different.
For example, in the test("read/write DistributedLDAModel"), I add the test:
val logPrior = model.asInstanceOf[DistributedLDAModel].logPrior
val logPrior2 = model2.asInstanceOf[DistributedLDAModel].logPrior
assert(logPrior === logPrior2)
The test fails:
-4.394180878889078 did not equal -4.294290536919573

The reason is that graph.vertices.aggregate(0.0)(seqOp, _ + _) only returns the value of a single vertex instead of the aggregation of all vertices. Therefore, when the loaded model does the aggregation in a different order, it returns different logPrior.

Please refer to #16464 for details.

How was this patch tested?

Add a new unit test for testing logPrior.

@wangmiao1981
Copy link
Contributor Author

Jenkins, retest this please.

@SparkQA
Copy link

SparkQA commented Jan 6, 2017

Test build #70992 has finished for PR 16491 at commit a29d078.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

val trainingLogLikelihood2 =
model2.asInstanceOf[DistributedLDAModel].trainingLogLikelihood
assert(logPrior ~== logPrior2 absTol 1e-6)
assert(trainingLogLikelihood ~== trainingLogLikelihood2 absTol 1e-6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check trainingLogLikelihood and logPrior are not changing for LocalLDAModel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logLikelihood and logPrior are only for distributed model.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right - I mean that they are not persisted & loaded into an unexpected but valid value (!= Double.NaN)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LocalLDAModel doesn't extend DistributedLDAModel and vice versa. I am not clear how to check trainingLogLikelihood and logPrior in LocalLDAModel.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I guess I remember this wrong because of the other PR.

@felixcheung
Copy link
Member

@jkbradley @yanboliang please have a look

@jkbradley
Copy link
Member

jkbradley commented Jan 7, 2017

Yikes, thanks for fixing this!
LGTM
Merging with master
I'll also try to merge it with branch-2.1, branch-2.0 but will say if I run into issues.

@asfgit asfgit closed this in 036b503 Jan 7, 2017
asfgit pushed a commit that referenced this pull request Jan 7, 2017
…or for original and loaded model

## What changes were proposed in this pull request?

While adding DistributedLDAModel training summary for SparkR, I found that the logPrior for original and loaded model is different.
For example, in the test("read/write DistributedLDAModel"), I add the test:
val logPrior = model.asInstanceOf[DistributedLDAModel].logPrior
val logPrior2 = model2.asInstanceOf[DistributedLDAModel].logPrior
assert(logPrior === logPrior2)
The test fails:
-4.394180878889078 did not equal -4.294290536919573

The reason is that `graph.vertices.aggregate(0.0)(seqOp, _ + _)` only returns the value of a single vertex instead of the aggregation of all vertices. Therefore, when the loaded model does the aggregation in a different order, it returns different `logPrior`.

Please refer to #16464 for details.
## How was this patch tested?
Add a new unit test for testing logPrior.

Author: [email protected] <[email protected]>

Closes #16491 from wangmiao1981/ldabug.

(cherry picked from commit 036b503)
Signed-off-by: Joseph K. Bradley <[email protected]>
asfgit pushed a commit that referenced this pull request Jan 7, 2017
…or for original and loaded model

## What changes were proposed in this pull request?

While adding DistributedLDAModel training summary for SparkR, I found that the logPrior for original and loaded model is different.
For example, in the test("read/write DistributedLDAModel"), I add the test:
val logPrior = model.asInstanceOf[DistributedLDAModel].logPrior
val logPrior2 = model2.asInstanceOf[DistributedLDAModel].logPrior
assert(logPrior === logPrior2)
The test fails:
-4.394180878889078 did not equal -4.294290536919573

The reason is that `graph.vertices.aggregate(0.0)(seqOp, _ + _)` only returns the value of a single vertex instead of the aggregation of all vertices. Therefore, when the loaded model does the aggregation in a different order, it returns different `logPrior`.

Please refer to #16464 for details.
## How was this patch tested?
Add a new unit test for testing logPrior.

Author: [email protected] <[email protected]>

Closes #16491 from wangmiao1981/ldabug.

(cherry picked from commit 036b503)
Signed-off-by: Joseph K. Bradley <[email protected]>
cmonkey pushed a commit to cmonkey/spark that referenced this pull request Jan 9, 2017
…or for original and loaded model

## What changes were proposed in this pull request?

While adding DistributedLDAModel training summary for SparkR, I found that the logPrior for original and loaded model is different.
For example, in the test("read/write DistributedLDAModel"), I add the test:
val logPrior = model.asInstanceOf[DistributedLDAModel].logPrior
val logPrior2 = model2.asInstanceOf[DistributedLDAModel].logPrior
assert(logPrior === logPrior2)
The test fails:
-4.394180878889078 did not equal -4.294290536919573

The reason is that `graph.vertices.aggregate(0.0)(seqOp, _ + _)` only returns the value of a single vertex instead of the aggregation of all vertices. Therefore, when the loaded model does the aggregation in a different order, it returns different `logPrior`.

Please refer to apache#16464 for details.
## How was this patch tested?
Add a new unit test for testing logPrior.

Author: [email protected] <[email protected]>

Closes apache#16491 from wangmiao1981/ldabug.
ghost pushed a commit to dbtsai/spark that referenced this pull request Jan 13, 2017
…nd logLikelihood of DistributedLDAModel in MLLIB

## What changes were proposed in this pull request?
apache#16491 added the fix to mllib and a unit test to ml. This followup PR, add unit tests to mllib suite.

## How was this patch tested?
Unit tests.

Author: [email protected] <[email protected]>

Closes apache#16524 from wangmiao1981/ldabug.
uzadude pushed a commit to uzadude/spark that referenced this pull request Jan 27, 2017
…or for original and loaded model

## What changes were proposed in this pull request?

While adding DistributedLDAModel training summary for SparkR, I found that the logPrior for original and loaded model is different.
For example, in the test("read/write DistributedLDAModel"), I add the test:
val logPrior = model.asInstanceOf[DistributedLDAModel].logPrior
val logPrior2 = model2.asInstanceOf[DistributedLDAModel].logPrior
assert(logPrior === logPrior2)
The test fails:
-4.394180878889078 did not equal -4.294290536919573

The reason is that `graph.vertices.aggregate(0.0)(seqOp, _ + _)` only returns the value of a single vertex instead of the aggregation of all vertices. Therefore, when the loaded model does the aggregation in a different order, it returns different `logPrior`.

Please refer to apache#16464 for details.
## How was this patch tested?
Add a new unit test for testing logPrior.

Author: [email protected] <[email protected]>

Closes apache#16491 from wangmiao1981/ldabug.
uzadude pushed a commit to uzadude/spark that referenced this pull request Jan 27, 2017
…nd logLikelihood of DistributedLDAModel in MLLIB

## What changes were proposed in this pull request?
apache#16491 added the fix to mllib and a unit test to ml. This followup PR, add unit tests to mllib suite.

## How was this patch tested?
Unit tests.

Author: [email protected] <[email protected]>

Closes apache#16524 from wangmiao1981/ldabug.
cmonkey pushed a commit to cmonkey/spark that referenced this pull request Feb 15, 2017
…nd logLikelihood of DistributedLDAModel in MLLIB

## What changes were proposed in this pull request?
apache#16491 added the fix to mllib and a unit test to ml. This followup PR, add unit tests to mllib suite.

## How was this patch tested?
Unit tests.

Author: [email protected] <[email protected]>

Closes apache#16524 from wangmiao1981/ldabug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants