Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the problem of trying to get edges which are not in the graph when running pra #23

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

IdelCoder
Copy link

  1. The change on code is only in PathFinder.scala. The other twos change nothing.
  2. To run pra, some spec_files need to change. The changes for me just runs OK.

Copy link
Owner

@matt-gardner matt-gardner left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I'm confused about some of the config file changes, though - I'm concerned you're actually changing behavior by removing some of them.

@@ -3,6 +3,7 @@
.classpath
.settings
.cache-main
.idea
Copy link
Owner

Choose a reason for hiding this comment

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

This should go in your global .gitignore file, not here. So should most of the other entries here, but I made this before learning better practices...

@@ -12,18 +12,11 @@ load new_feature_experiment_base
"spikiness": 3,
"reset weight": 0.25,
"embeddings": "pca_svo"
},
"walks per source": 100,
Copy link
Owner

Choose a reason for hiding this comment

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

Are you sure removing all of these parameters is correct, here?

"path follower": {
"walks per path": 50,
"matrix accept policy": "paired-targets-only"
"embeddings": "/tienan/pra/examples/embeddings/pca_svo/embeddings.tsv"
Copy link
Owner

Choose a reason for hiding this comment

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

Can you remove your machine-specific path, here? Something like /embedding_dir/pca_svo/embeddings.tsv would be better - it's more obvious that a user is intended to change the path this way. Also, the code used to not require you to give a full path... Not sure if you can just use "pca_svo" here any more or not. It's been quite a while since I touched this code.

@@ -201,9 +201,10 @@ class GraphChiPathFinder(
// and the rest of the columns make up the vector.
fileUtil.readLinesFromFile(embeddingsFile).map(line => {
Copy link
Owner

Choose a reason for hiding this comment

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

There's a slightly more idiomatic way to do this in scala, using flatMap instead of a filter:

fileUtil.readLinesFromFile(embeddingsFile).flatMap(line => {
  val fields = line.split("\t");
  if (graph.hasEdge(fields(0))) {
    val relationIndex = graph.getEdgeIndex(fields(0))
    val vector = fields.drop(1).map(_.toDouble)
    Seq((relationIndex, new Vector(vector)))
  } else {
    Seq()
  }
}.toMap

This saves a tiny bit of memory and processing time, also, as you're not constructing vectors unless the edge is in the graph.

@@ -1,19 +1,16 @@
package edu.cmu.ml.rtw.pra.features

import edu.cmu.ml.rtw.pra.data.Dataset
import edu.cmu.ml.rtw.pra.data.NodePairInstance
import edu.cmu.ml.rtw.pra.data.{Dataset, NodePairInstance, Instance}
Copy link
Owner

Choose a reason for hiding this comment

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

This added import is unused - I think you can just revert all of the changes to this file.

@IdelCoder
Copy link
Author

Sorry for late reply and my poor programming. I once tried to alter the path of "embeddings" to be relative. So I tried to made some change on the code but failed.

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.

2 participants