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
serialize(modelFile+"-iter-"+trainer.iteration) | |
val other = ClassifierPos.load(modelFile+"-iter-"+trainer.iteration) | |
val od = other.ClassifierPosFeatureDomain.dimensionDomain | |
val s0 = testDocs.head.sentences.head | |
val sd0 = new SentenceData(s0) | |
val sd1 = new other.SentenceData(s0) | |
sd0.lemmas.zipWithIndex.foreach(l => assert(sd1.lemmas(l._2) == l._1)) | |
val f0 = new SparseBinaryTensor1(ClassifierPosFeatureDomain.dimensionDomain.size) | |
val f1 = new SparseBinaryTensor1(other.ClassifierPosFeatureDomain.dimensionDomain.size) | |
assert(ClassifierPosFeatureDomain.dimensionDomain.size == other.ClassifierPosFeatureDomain.dimensionDomain.size) |
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
class StringMapCubbie[T](val m: mutable.Map[String,T]) extends Cubbie { | |
var akeys : Seq[String] = null | |
var avalues: Seq[T] = null | |
setMap(new mutable.Map[String, Any] { | |
override def update(key: String, value: Any): Unit = { | |
if (key == "keys") { | |
akeys = value.asInstanceOf[Traversable[String]].toSeq | |
} else if (key == "values") { | |
assert(keys != null) | |
avalues = value.asInstanceOf[Traversable[T]].toSeq |
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
trait Foo { | |
def a: String | |
val b = a + " " | |
} | |
class Bar extends Foo { override val a = "a" } | |
class Baz extends Foo { override def a = "a" } | |
class Bla extends Foo { override lazy val a = "a" } | |
// guess what the code below prints | |
println(new Bar().b) |
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
import argparse | |
import numpy as np | |
import tensorflow as tf | |
from tensorflow.python.framework.errors import FailedPreconditionError | |
"""Code for data dependent initialization in Weight Normalization paper: | |
https://arxiv.org/abs/1602.07868 | |
""" |
OlderNewer