Created
November 24, 2010 19:05
-
-
Save eob/714195 to your computer and use it in GitHub Desktop.
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
def initializeToCrfPosteriors = { | |
_Y = emptyY // Initialize to all 0s | |
require (_Y.size == _crfPotentials.size) // Santiy check: both are over tweets | |
for (tweet <- 0 until _crfPotentials.size) { | |
_forwardBackward.setInput(_crfPotentials(tweet)) | |
val nodeMarginals = _forwardBackward.getNodeMarginals() | |
val nonBorderMarginals = nodeMarginals.slice(1, nodeMarginals.size - 1) | |
require (nonBorderMarginals.size == _Y(tweet).size) // Santiy check: both are over tokens | |
for (token <- 0 until nonBorderMarginals.size) { | |
require (nonBorderMarginals(token).size == _Y(tweet)(token).size) // Santiy check: both are over labels | |
for (label <- 0 until nonBorderMarginals(token).size) { | |
_Y(tweet)(token)(label) = nonBorderMarginals(token)(label) | |
} | |
} | |
} | |
checkOK // Ensure proper distribution | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment