本文整理汇总了Java中cc.mallet.fst.MEMM.addStartState方法的典型用法代码示例。如果您正苦于以下问题:Java MEMM.addStartState方法的具体用法?Java MEMM.addStartState怎么用?Java MEMM.addStartState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.fst.MEMM
的用法示例。
在下文中一共展示了MEMM.addStartState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSpaceSerializable
import cc.mallet.fst.MEMM; //导入方法依赖的package包/类
public void testSpaceSerializable () throws IOException, ClassNotFoundException
{
Pipe p = makeSpacePredictionPipe ();
InstanceList training = new InstanceList (p);
training.addThruPipe (new ArrayIterator (data));
MEMM memm = new MEMM (p, null);
memm.addFullyConnectedStatesForLabels ();
memm.addStartState();
memm.setWeightsDimensionAsIn(training);
MEMMTrainer memmt = new MEMMTrainer (memm);
memmt.train (training, 10);
MEMM memm2 = (MEMM) TestSerializable.cloneViaSerialization (memm);
Optimizable.ByGradientValue mcrf1 = memmt.getOptimizableMEMM(training);
double val1 = mcrf1.getValue ();
Optimizable.ByGradientValue mcrf2 = memmt.getOptimizableMEMM(training);
double val2 = mcrf2.getValue ();
assertEquals (val1, val2, 1e-5);
}
示例2: ignoretestSpaceSerializable
import cc.mallet.fst.MEMM; //导入方法依赖的package包/类
public void ignoretestSpaceSerializable () throws IOException, ClassNotFoundException
{
Pipe p = makeSpacePredictionPipe ();
InstanceList training = new InstanceList (p);
training.addThruPipe (new ArrayIterator (data));
MEMM memm = new MEMM (p, null);
memm.addFullyConnectedStatesForLabels ();
memm.addStartState();
memm.setWeightsDimensionAsIn(training);
MEMMTrainer memmt = new MEMMTrainer (memm);
memmt.train (training, 10);
MEMM memm2 = (MEMM) TestSerializable.cloneViaSerialization (memm);
Optimizable.ByGradientValue mcrf1 = memmt.getOptimizableMEMM(training);
double val1 = mcrf1.getValue ();
Optimizable.ByGradientValue mcrf2 = memmt.getOptimizableMEMM(training);
double val2 = mcrf2.getValue ();
assertEquals (val1, val2, 1e-5);
}
示例3: testSpaceMaximizable
import cc.mallet.fst.MEMM; //导入方法依赖的package包/类
public void testSpaceMaximizable ()
{
Pipe p = makeSpacePredictionPipe ();
InstanceList training = new InstanceList (p);
// String[] data = { TestMEMM.data[0], }; // TestMEMM.data[1], TestMEMM.data[2], TestMEMM.data[3], };
// String[] data = { "ab" };
training.addThruPipe (new ArrayIterator (data));
// CRF4 memm = new CRF4 (p, null);
MEMM memm = new MEMM (p, null);
memm.addFullyConnectedStatesForLabels ();
memm.addStartState();
memm.setWeightsDimensionAsIn(training);
MEMMTrainer memmt = new MEMMTrainer (memm);
// memm.gatherTrainingSets (training); // ANNOYING: Need to set up per-instance training sets
memmt.train (training, 1); // Set weights dimension, gathers training sets, etc.
// memm.print();
// memm.printGradient = true;
// memm.printInstanceLists();
// memm.setGaussianPriorVariance (Double.POSITIVE_INFINITY);
Optimizable.ByGradientValue mcrf = memmt.getOptimizableMEMM(training);
TestOptimizable.setNumComponents (150);
TestOptimizable.testValueAndGradient (mcrf);
}
示例4: ignoretestSpaceMaximizable
import cc.mallet.fst.MEMM; //导入方法依赖的package包/类
public void ignoretestSpaceMaximizable ()
{
Pipe p = makeSpacePredictionPipe ();
InstanceList training = new InstanceList (p);
// String[] data = { TestMEMM.data[0], }; // TestMEMM.data[1], TestMEMM.data[2], TestMEMM.data[3], };
// String[] data = { "ab" };
training.addThruPipe (new ArrayIterator (data));
// CRF4 memm = new CRF4 (p, null);
MEMM memm = new MEMM (p, null);
memm.addFullyConnectedStatesForLabels ();
memm.addStartState();
memm.setWeightsDimensionAsIn(training);
MEMMTrainer memmt = new MEMMTrainer (memm);
// memm.gatherTrainingSets (training); // ANNOYING: Need to set up per-instance training sets
memmt.train (training, 1); // Set weights dimension, gathers training sets, etc.
// memm.print();
// memm.printGradient = true;
// memm.printInstanceLists();
// memm.setGaussianPriorVariance (Double.POSITIVE_INFINITY);
Optimizable.ByGradientValue mcrf = memmt.getOptimizableMEMM(training);
TestOptimizable.setNumComponents (150);
TestOptimizable.testValueAndGradient (mcrf);
}