本文整理汇总了Java中water.H2O.H2OCallback类的典型用法代码示例。如果您正苦于以下问题:Java H2OCallback类的具体用法?Java H2OCallback怎么用?Java H2OCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
H2OCallback类属于water.H2O包,在下文中一共展示了H2OCallback类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fork
import water.H2O.H2OCallback; //导入依赖的package包/类
@Override public MatrixMulJob fork(){
Futures fs = new Futures();
DKV.put(_dstKey, new MatrixMulStats(_x.anyVec().nChunks()* _y.numCols(),self()),fs);
fs.blockForPending();
start(new H2OEmptyCompleter());
H2O.submitTask(new MatrixMulTsk(new H2OCallback<MatrixMulTsk>(_fjtask) { // cleanup
@Override
public void callback(MatrixMulTsk mmt) {
_z = mmt._z;
DKV.put(_dstKey,_z);
remove();
}
@Override public boolean onExceptionalCompletion(Throwable ex, CountedCompleter caller) {
MatrixMulJob.this.cancel(ex);
return true;
}
},_dstKey, _x,_y));
return this;
}
示例2: compute2
import water.H2O.H2OCallback; //导入依赖的package包/类
@Override
protected void compute2() {
// get filtered dataset's mean and number of observations
new YMUTask(_dinfo, _dinfo._adaptedFrame.anyVec().makeZero(), new H2OCallback<YMUTask>(this) {
@Override
public void callback(final YMUTask ymut) {
_rowFilter = ymut._fVec;
_ymu = _parms._intercept ? ymut._ymu : 0;
_wsum = ymut._wsum;
_ymuLink = _parms._intercept ? _parms.link(_ymu):0;
_yMin = ymut._yMin;
_yMax = ymut._yMax;
_nobs = ymut._nobs;
if(ymut._comupteWeightedSigma) { // got weights, need to recompute standardization
double [] sigmas = MemoryManager.malloc8d(_dinfo._nums);
double [] mean = MemoryManager.malloc8d(_dinfo._nums);
for(int i = 0; i < _dinfo._nums; ++i) {
sigmas[i] = MathUtils.weightedSigma(ymut._nobs, ymut._wsum, ymut._xsum[i], ymut._xxsum[i]);
mean[i] = ymut._xsum[i]/ymut._wsum;
}
_dinfo.updateWeightedSigmaAndMean(sigmas, mean);
}
if(_dinfo._offset && _parms._intercept) {
InitTsk.this.addToPendingCount(1);
DataInfo dinfo = _dinfo.filterExpandedColumns(new int[]{});
new GLMIterationTask(GLM.this._key,dinfo,0,_parms,false,new double[]{_parms.link(_response.mean()) - _offset.mean()},0,_rowFilter, new NullModelIteration(dinfo)).asyncExec(dinfo._adaptedFrame);
} else
computeGradients();
}
}).asyncExec(_dinfo._adaptedFrame);
}
示例3: start
import water.H2O.H2OCallback; //导入依赖的package包/类
static void start(final Vec vec, Futures fs, boolean computeHisto) {
if( DKV.get(vec._key)== null ) throw new RuntimeException("Rollups not possible, because Vec was deleted: "+vec._key);
final Key rskey = vec.rollupStatsKey();
RollupStats rs = getOrNull(vec);
if(rs == null || computeHisto && !rs.hasHisto())
fs.add(new RPC(rskey.home_node(),new ComputeRollupsTask(vec,computeHisto)).addCompleter(new H2OCallback() {
@Override
public void callback(H2OCountedCompleter h2OCountedCompleter) {
DKV.get(rskey); // fetch new results via DKV to enable caching of the results.
}
}).call());
}
示例4: forkVecTask
import water.H2O.H2OCallback; //导入依赖的package包/类
private void forkVecTask(final int i) {
new GetNonZerosTsk(new H2OCallback<GetNonZerosTsk>(this) {
@Override
public void callback(GetNonZerosTsk gnz) {
new VecTsk(new Callback(), _progressKey, gnz._vals).asyncExec(ArrayUtils.append(_x.vecs(gnz._idxs), _z.vec(i)));
}
}).asyncExec(_y.vec(i));
}
示例5: setupLocal
import water.H2O.H2OCallback; //导入依赖的package包/类
@Override public void setupLocal() {
final H2OCountedCompleter barrier = (new H2OCountedCompleter() {
@Override
protected void compute2() {
}
});
barrier.addToPendingCount(_keys.length-1);
for(Key k:_keys)DKV.get(k);
for (int i = 0; i < _keys.length; ++i) {
final Key fk = _keys[i];
new AtomicIncrementAndGet(new H2OCallback<AtomicIncrementAndGet>(barrier) {
@Override
public void callback(AtomicIncrementAndGet f) {
final int lb = f._val;
for(H2ONode node:H2O.CLOUD._memary) {
if(node != H2O.SELF) {
barrier.addToPendingCount(1);
new RPC(node,new DTask() {
@Override
protected void compute2() {
IcedInt val = DKV.getGet(fk);
if (val._val < lb)
throw new IllegalArgumentException("DKV seems to be in inconsistent state after TAtomic, value lower than expected, expected at least " + lb + ", got " + val._val);
tryComplete();
}
}).addCompleter(barrier).call();
}
}
}
}).fork(_keys[i]);
}
barrier.join();
}
示例6: start
import water.H2O.H2OCallback; //导入依赖的package包/类
static void start(final Vec vec, Futures fs, boolean computeHisto) {
if( vec instanceof InteractionWrappedVec ) return;
if( DKV.get(vec._key)== null )
throw new RuntimeException("Rollups not possible, because Vec was deleted: "+vec._key);
if( vec.isString() ) computeHisto = false; // No histogram for string columns
final Key rskey = vec.rollupStatsKey();
RollupStats rs = getOrNull(vec,rskey);
if(rs == null || (computeHisto && !rs.hasHisto()))
fs.add(new RPC(rskey.home_node(),new ComputeRollupsTask(vec,computeHisto)).addCompleter(new H2OCallback() {
@Override public void callback(H2OCountedCompleter h2OCountedCompleter) {
DKV.get(rskey); // fetch new results via DKV to enable caching of the results.
}
}).call());
}
示例7: forkVecTask
import water.H2O.H2OCallback; //导入依赖的package包/类
private void forkVecTask(final int i) {
new GetNonZerosTsk(new H2OCallback<GetNonZerosTsk>(this) {
@Override
public void callback(GetNonZerosTsk gnz) {
new VecTsk(new Callback(), _progressKey, gnz._vals).dfork(ArrayUtils.append(_x.vecs(gnz._idxs), _z.vec(i)));
}
}).dfork(_y.vec(i));
}
示例8: setupLocal
import water.H2O.H2OCallback; //导入依赖的package包/类
@Override public void setupLocal() {
final H2OCountedCompleter barrier = (new H2OCountedCompleter() {
@Override
public void compute2() {
}
});
barrier.addToPendingCount(_keys.length-1);
for(Key k:_keys)DKV.get(k);
for (int i = 0; i < _keys.length; ++i) {
final Key fk = _keys[i];
new AtomicIncrementAndGet(new H2OCallback<AtomicIncrementAndGet>(barrier) {
@Override
public void callback(AtomicIncrementAndGet f) {
final int lb = f._val;
for(H2ONode node:H2O.CLOUD._memary) {
if(node != H2O.SELF) {
barrier.addToPendingCount(1);
new RPC(node,new DTask() {
@Override
public void compute2() {
IcedInt val = DKV.getGet(fk);
if (val._val < lb)
throw new IllegalArgumentException("DKV seems to be in inconsistent state after TAtomic, value lower than expected, expected at least " + lb + ", got " + val._val);
tryComplete();
}
}).addCompleter(barrier).call();
}
}
}
}).fork(_keys[i]);
}
barrier.join();
}
示例9: serve
import water.H2O.H2OCallback; //导入依赖的package包/类
@Override
protected Response serve() {
if(n > 10000) // global order not supported
throw H2O.unimpl();
long [] espc = new long[]{0,n};
final Vec [] dst = new Vec(Vec.newKey(),espc).makeZeros(cols.length);
H2OEmptyCompleter cmp = new H2OEmptyCompleter();
cmp.setPendingCount(cols.length-1);
final int addOne = (add_one?1:0);
for(int i = 0; i < cols.length; ++i) {
final int fi = i;
new OrderTsk(new H2OCallback<OrderTsk>(cmp) {
@Override
public void callback(OrderTsk ot) {
Vec.Writer w = dst[fi].open();
for (int j = 0; j < ot._ids.length; ++j)
w.set(j, ot._ids[j] + addOne);
w.close();
}
}, n, rev).asyncExec(source.vec(cols[i]));
}
cmp.join();
Futures fs = new Futures();
if(destination_key == null)
destination_key = Key.make(source._key.toString() + ".order");
DKV.put(destination_key, new Frame(destination_key, Utils.select(source.names(), cols),dst),fs);
fs.blockForPending();
return Inspect2.redirect(this, destination_key.toString());
}
示例10: forkVecTask
import water.H2O.H2OCallback; //导入依赖的package包/类
private void forkVecTask(final int i) {
new GetNonZerosTsk(new H2OCallback<GetNonZerosTsk>(this) {
@Override
public void callback(GetNonZerosTsk gnz) {
new VecTsk(new Callback(), _progressKey, gnz._vals).asyncExec(Utils.append(_x.vecs(gnz._idxs), _z.vec(i)));
}
}).asyncExec(_y.vec(i));
}