本文整理汇总了Java中edu.berkeley.nlp.mapper.AsynchronousMapper类的典型用法代码示例。如果您正苦于以下问题:Java AsynchronousMapper类的具体用法?Java AsynchronousMapper怎么用?Java AsynchronousMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AsynchronousMapper类属于edu.berkeley.nlp.mapper包,在下文中一共展示了AsynchronousMapper类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doIter
import edu.berkeley.nlp.mapper.AsynchronousMapper; //导入依赖的package包/类
private double doIter() {
List<GradMapper> gradMappers = new ArrayList<GradMapper>();
for (ObjectiveItemDifferentiableFunction<I> itemFn : itemFns) {
gradMappers.add(new GradMapper(itemFn));
}
List<I> shuffledItems = shuffleData ? CollectionUtils.shuffle(items,
rand) : new ArrayList<I>(items);
AsynchronousMapper.doMapping(shuffledItems, gradMappers);
// List<ValMapper> valMappers = new ArrayList<ValMapper>();
// for (ObjectiveItemDifferentiableFunction<I> itemFn : itemFns) {
// valMappers.add(new ValMapper(itemFn));
// }
// AsynchronousMapper.doMapping(items,valMappers);
double val = 0.0;
for (GradMapper mapper : gradMappers) {
val += mapper.val;
}
return val;
}
示例2: calculate
import edu.berkeley.nlp.mapper.AsynchronousMapper; //导入依赖的package包/类
@Override
protected Pair<Double, double[]> calculate(double[] x) {
for (ObjectiveItemDifferentiableFunction<I> itemFn : itemFns) {
itemFn.setWeights(x);
}
List<Mapper> mappers = getMappers();
AsynchronousMapper.doMapping(items, mappers);
double objVal = 0.0;
double[] grad = new double[dimension()];
for (Mapper mapper : mappers) {
objVal += mapper.objVal;
DoubleArrays.addInPlace(grad, mapper.localGrad);
}
if (regularizer != null) {
objVal += regularizer.update(x, grad, 1.0);
}
return Pair.newPair(objVal, grad);
}
示例3: doIter
import edu.berkeley.nlp.mapper.AsynchronousMapper; //导入依赖的package包/类
private double doIter() {
List<Mapper> mappers = new ArrayList<Mapper>();
for (ObjectiveItemDifferentiableFunction<I> itemFn : itemFns) {
mappers.add(new Mapper(itemFn));
}
AsynchronousMapper.doMapping(items, mappers);
double val = 0.0;
for (Mapper mapper : mappers) {
val += mapper.val;
}
return val;
}