Modified:
/branches/thefuture-modules/thebeast-core/src/main/scala/org/riedelcastro/thebeast/env/doubles/LogLinear.scala
/branches/thefuture-modules/thebeast-core/src/test/scala/org/riedelcastro/thebeast/learn/OnlineLearnerSpecification.scala
=======================================
---
/branches/thefuture-modules/thebeast-core/src/main/scala/org/riedelcastro/thebeast/env/doubles/LogLinear.scala
Thu Mar 25 18:57:19 2010
+++
/branches/thefuture-modules/thebeast-core/src/main/scala/org/riedelcastro/thebeast/env/doubles/LogLinear.scala
Thu Mar 25 19:41:49 2010
@@ -24,10 +24,15 @@
}
object LogLinearMatch {
+
def unapply(term:DoubleTerm):Option[(VectorTerm,VectorVar,DoubleTerm)] =
term match {
+ case
Exp(Sum(Seq(VectorDotApp(sufficient,weights:VectorVar),bias:DoubleTerm)))
=> Some((sufficient,weights,bias))
+ case
Exp(Sum(Seq(VectorDotApp(weights:VectorVar,sufficient),bias:DoubleTerm)))
=> Some((sufficient,weights,bias))
+ case Exp(VectorDotApp(sufficient,weights:VectorVar)) =>
Some((sufficient,weights,DoubleConstant(0.0)))
+ case Exp(VectorDotApp(weights:VectorVar,sufficient)) =>
Some((sufficient,weights,DoubleConstant(0.0)))
case LogLinear(sufficient,weights,bias) =>
Some((sufficient,weights,bias))
case _ => None
- }
+ }
}
/**
=======================================
---
/branches/thefuture-modules/thebeast-core/src/test/scala/org/riedelcastro/thebeast/learn/OnlineLearnerSpecification.scala
Thu Mar 25 18:57:19 2010
+++
/branches/thefuture-modules/thebeast-core/src/test/scala/org/riedelcastro/thebeast/learn/OnlineLearnerSpecification.scala
Thu Mar 25 19:41:49 2010
@@ -31,7 +31,8 @@
{(c1,c2,c3)=>$((same(c1,c2) && same(c2,c3)) ~>
same(c1,c3)) * UnitVector("trans")}
val theta = new VectorVar("theta")
- val unnormalized = LogLinear(features, theta, 0.0) ? same
+// val unnormalized = LogLinear(features, theta, 0.0) ? same
+ val unnormalized = exp(features dot theta) ? same
val model = normalize(unnormalized)
val ll = SumOverGroundings(model,Seq(y1,y2)) ? theta