-
Notifications
You must be signed in to change notification settings - Fork 0
Reorganized TokenClassificationHead to use the Sequential module. Added optional nonlinearity. #59
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
Conversation
@kwalcock : I added you as reviewer here and I'd be happy if you are willing to continue keeping an eye on these projects. I see you as a key contributor to these projects, which will continue as open source. But, of course, this is completely optional! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions will be there momentarily in a PR.
if(nonLin.isDefined) { | ||
for (matrix <- outputs) { | ||
for (i <- 0 until Math.rows(matrix)) { | ||
val row = Math.row(matrix, i) | ||
for (j <- 0 until Math.cols(matrix)) { | ||
val orig = Math.get(row, j) | ||
Math.set(row, j, nonLin.get.compute(orig)) | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we don't have a map method. It might be nice to hide these details and maybe make it more efficient with code like
def map(matrix: MathRowMatrix, f: MathValue => MathValue): Unit = {
val iterator = matrix.iterator(true, 0, 0, matrix.getNumRows, matrix.getNumCols)
while (iterator.hasNext) {
val oldValue = iterator.next()
val newValue = f(oldValue)
iterator.set(newValue)
}
}
Then the Encoder would have
nonLinOpt.foreach { nonLin =>
outputs.foreach { matrix =>
Math.map(matrix, nonLin.compute)
}
}
There will be an example PR with other details soon.
@@ -0,0 +1,15 @@ | |||
package org.clulab.scala_transformers.encoder | |||
|
|||
import org.clulab.scala_transformers.encoder.math.EjmlMath.MathValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a way to make this independent of EjmlMath.
val row = Math.row(matrix, i) | ||
for (j <- 0 until Math.cols(matrix)) { | ||
val orig = Math.get(row, j) | ||
Math.set(row, j, nonLin.get.compute(orig)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this does stay, the nonLin.get
might be moved outside the triply nested loops.
PS I'm not sure what happened to sbt that is preventing testing. I'll try to check up on it. |
No description provided.