water.H2O.submitTask()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中water.H2O.submitTask()方法的一些代码示例,展示了H2O.submitTask()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。H2O.submitTask()方法的具体详情如下:
包路径:water.H2O
类名称:H2O
方法名:submitTask

H2O.submitTask介绍

暂无

代码示例

代码示例来源:origin: h2oai/h2o-2

public void submitTask() {H2O.submitTask(this);}
public void forkTask() {fork();}

代码示例来源:origin: h2oai/h2o-2

public T invokeTask() {
  H2O.submitTask(this);
  join();
  return (T)this;
 }
}

代码示例来源:origin: h2oai/h2o-2

@Override protected void closeLocal() {
 // Launch actual computation in order, otherwise passes
 // between chunks diverge quickly
 DescentEpoch epoch = new DescentEpoch();
 epoch._node = _node;
 epoch._count = _epochs == 0. ? -1 : (int)Math.ceil(_epochs);
 H2O.submitTask(epoch);
 _ls = null;
 _ws = null;
 _bs = null;
 _key = null;
}

代码示例来源:origin: h2oai/h2o-2

public static Vec[] rebalanceAndReplace(int nchunks, int maxP, Vec... vecs) {
 RebalanceAndReplaceDriver rbt = new RebalanceAndReplaceDriver(nchunks, maxP, vecs);
 H2O.submitTask(rbt).join();
 return rbt._newVecs;
}
public static class RebalanceTask extends MRTask2<RebalanceTask> {

代码示例来源:origin: h2oai/h2o-2

/**
 * Task to compare the two frames, returns true if they are identical.
 * We can't in general expect frames to be bit-compatible so we compare the numbers,
 * integers are compared exaclty, doubles only with given precision (1e-8 is default).
 * (compression scheme may be altered by the way they were parsed and by rebalancing)
 * The frames are expected to be compatible.
 * @param f
 * @return
 */
public final boolean isIdentical(Frame f){
 FrameIdenticalTask fbt = new FrameIdenticalTask(this,f);
 H2O.submitTask(fbt);
 fbt.join();
 return fbt._res;
}
public static class FrameIdenticalTask extends H2OCountedCompleter {

代码示例来源:origin: h2oai/h2o-3

public boolean Next(Futures fs) throws IOException {
 if (_start_index < _rows_lst.size()) {
  if (_start_index + _batch_size > _rows_lst.size())
   _start_index = _rows_lst.size() - _batch_size;
  // Multi-Threaded data preparation
  for (int i = 0; i < _batch_size; i++)
   fs.add(H2O.submitTask(new FrameDataConverter(i, _rows_lst.get(_start_index+i), _dinfo, _label_lst==null?-1:_label_lst.get(_start_index + i), _data[which()], _label[which()], _cache)));
  fs.blockForPending();
  flip();
  _start_index += _batch_size;
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: h2oai/h2o-3

/**
 * Helper to convert a Matrix into a Frame
 *
 * @param m Matrix
 * @param key Key for output Frame
 * @return Reference to Frame (which is also in DKV)
 */
private static Frame toFrame(Matrix m, Key<Frame> key) {
 H2O.submitTask(new ConvertMatrixToFrame(m, key)).join();
 Frame f = DKV.getGet(key);
 assert f != null;
 return f;
}

代码示例来源:origin: h2oai/h2o-2

@Override public void compute2() {
  if( (_count < 0 || --_count >= 0) && (_node._job == null || Job.isRunning(_node._job)) ) {
   for( Chunk[] cs : _node._chunks ) {
    DescentChunk task = new DescentChunk();
    task._node = _node;
    task._cs = cs;
    H2O.submitTask(task);
   }
   reinitialize();
   H2O.submitTask(this);
  } else {
   if( _node._key.home() )
    _node._trainer.done();
  }
 }
}

代码示例来源:origin: h2oai/h2o-3

static EfronDJKSetupFun setupEfron(CoxPHTask coxMR) {
 EfronDJKSetupFun djkTermSetup = new EfronDJKSetupFun(coxMR);
 H2O.submitTask(new LocalMR(djkTermSetup, coxMR.sizeEvents.length)).join();
 return djkTermSetup.postProcess();
}

代码示例来源:origin: h2oai/h2o-3

public boolean Next(Futures fs) throws IOException {
 if (_start_index < _num_obs) {
  if (_start_index + _batch_size > _num_obs)
   _start_index = _num_obs - _batch_size;
  // Multi-Threaded data preparation
  for (int i = 0; i < _batch_size; i++)
   fs.add(H2O.submitTask(new TextConverter(i, _start_index + i, _txt_list.get(_start_index +i),
     _label_lst == null?Float.NaN : _label_lst.get(_start_index +i),_data[which()], _wordsPerLine, _label[which()], _cache)));
  fs.blockForPending();
  flip();
  _start_index = _start_index + _batch_size;
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: h2oai/h2o-2

private void forkDTask(final int i, H2ONode n){
 _tasks[i] = new GLMT(new Callback(n,i),_glms[i],_lambda);
 assert Double.isNaN(_lambda) || _tasks[i]._glm._lastResult._fullGrad != null;
 if(n == H2O.SELF) H2O.submitTask(_tasks[i]);
 else new RPC(n,_tasks[i]).call();
}
class Callback extends H2OCallback<H2OCountedCompleter> {

代码示例来源:origin: h2oai/h2o-2

public static KeySnapshot globalSnapshot(long timeTolerance){
 KeySnapshot res = _cache;
 final long t = System.currentTimeMillis();
 if(res == null || (t - _lastUpdate) > timeTolerance)
  res = new KeySnapshot(new GlobalUKeySetTask().invokeOnAllNodes()._res);
 else if(t - _lastUpdate > _updateInterval)
  H2O.submitTask(new H2OCountedCompleter() {
   @Override
   public void compute2() {
    new GlobalUKeySetTask().invokeOnAllNodes();
   }
  });
 return res;
}
private static class GlobalUKeySetTask extends DRemoteTask<GlobalUKeySetTask> {

代码示例来源:origin: h2oai/h2o-2

@Override public RequestBuilders.Response serve() {
 if( source==null ) throw new IllegalArgumentException("Missing frame to rebalance!");
 try {
  if (chunks > source.numRows()) throw new IllegalArgumentException("Cannot create more than " + source.numRows() + " chunks.");
  if( after==null ) after = Key.make(source._key.toString() + ".balanced");
  RebalanceDataSet rb = new RebalanceDataSet(source, after, chunks);
  H2O.submitTask(rb);
  rb.join();
  return RequestBuilders.Response.done(this);
 } catch( Throwable t ) {
  return RequestBuilders.Response.error(t);
 }
}

代码示例来源:origin: h2oai/h2o-3

public boolean Next(Futures fs) throws IOException {
 if (_start_index < _num_obs) {
  if (_start_index + _batch_size > _num_obs)
   _start_index = _num_obs - _batch_size;
  // Multi-Threaded data preparation
  Conversion conv = new Conversion();
  conv._dim._height=this._height;
  conv._dim._width=this._width;
  conv._dim._channels=this._channels;
  for (int i = 0; i < _batch_size; i++)
   fs.add(H2O.submitTask(new ImageConverter(i, _img_lst.get(_start_index +i), _label_lst ==null?Float.NaN: _label_lst.get(_start_index +i),conv, _data[which()], _meanData, _label[which()], _cache)));
  fs.blockForPending();
  flip();
  _start_index = _start_index + _batch_size;
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: h2oai/h2o-3

private void fitBestConstantsQuantile(DTree[] ktrees, int firstLeafIndex, double quantile) {
 if (firstLeafIndex == ktrees[0]._len) return; // no splits happened - nothing to do
 assert(_nclass==1);
 Vec diff = new ComputeDiff(frameMap).doAll(1, (byte)3 /*numeric*/, _train).outputFrame().anyVec();
 Vec weights = hasWeightCol() ? _train.vecs()[idx_weight()] : null;
 Vec strata = vec_nids(_train,0);
 // compute quantile for all leaf nodes
 Quantile.StratifiedQuantilesTask sqt = new Quantile.StratifiedQuantilesTask(null, quantile, diff, weights, strata, QuantileModel.CombineMethod.INTERPOLATE);
 H2O.submitTask(sqt);
 sqt.join();
 final DTree tree = ktrees[0];
 for (int i = 0; i < sqt._quantiles.length; i++) {
  if (Double.isNaN(sqt._quantiles[i])) continue; //no active rows for this NID
  double val = effective_learning_rate() * sqt._quantiles[i];
  assert !Double.isNaN(val) && !Double.isInfinite(val);
  if (val > _parms._max_abs_leafnode_pred) val = _parms._max_abs_leafnode_pred;
  if (val < -_parms._max_abs_leafnode_pred) val = -_parms._max_abs_leafnode_pred;
  ((LeafNode) tree.node(sqt._nids[i]))._pred = (float) val;
  if (DEV_DEBUG) { Log.info("Leaf " + sqt._nids[i] + " has quantile: " + sqt._quantiles[i]); }
 }
}

代码示例来源:origin: h2oai/h2o-2

@Override protected void execImpl() {
 NFoldFrameExtractor extractor = new NFoldFrameExtractor(source, nfolds, afold, null, null);
 H2O.submitTask(extractor);
 Frame[] splits = extractor.getResult();
 split_keys = new Key [splits.length];
 split_rows = new long[splits.length];
 long sum = 0;
 for(int i=0; i<splits.length; i++) {
  sum += splits[i].numRows();
  split_keys[i] = splits[i]._key;
  split_rows[i] = splits[i].numRows();
 }
 assert sum == source.numRows() : "Frame split produced wrong number of rows: nrows(source) != sum(nrows(splits))";
}

代码示例来源:origin: h2oai/h2o-3

static ComputationState calcLoglik(DataInfo dinfo, CoxPHTask coxMR, ComputationState cs) {
 EfronDJKSetupFun djkTermSetup = EfronDJKSetupFun.setupEfron(coxMR);
 EfronDJKTermTask djkTermTask = new EfronDJKTermTask(dinfo, coxMR, djkTermSetup).doAll(dinfo._adaptedFrame);
 EfronUpdateFun f = new EfronUpdateFun(cs, coxMR);
 H2O.submitTask(new LocalMR(f, coxMR.sizeEvents.length)).join();
 for (int i = 0; i < f._n_coef; i++)
  for (int j = 0; j < f._n_coef; j++)
   f._hessian[i][j] += djkTermTask._djkTerm[i][j];
 for (int i = 0; i < f._n_coef; i++)
  f._gradient[i] += coxMR.sumXEvents[i];
 return f.toComputationState(cs);
}

代码示例来源:origin: h2oai/h2o-2

public Frame makeCompatible( Frame f) {
 // Small data frames are always "compatible"
 if( anyVec()==null)      // Or it is small
  return f;                 // Then must be compatible
 // Same VectorGroup is also compatible
 if( f.anyVec() == null ||
   f.anyVec().group().equals(anyVec().group()) && Arrays.equals(f.anyVec()._espc,anyVec()._espc))
  return f;
 // Ok, here make some new Vecs with compatible layout
 Key k = Key.make();
 H2O.submitTask(new RebalanceDataSet(this, f, k)).join();
 Frame f2 = DKV.get(k).get();
 DKV.remove(k);
 return f2;
}

代码示例来源:origin: h2oai/h2o-3

@Test
public void testBuildConcurrent() {
 Scope.enter();
 try {
  Frame fr = parse_test_file(Key.make("prostate_concurrent.hex"), "smalldata/logreg/prostate.csv");
  Scope.track(fr);
  fr.remove("ID").remove();
  DKV.put(fr);
  TrainSingleFun fun = new TrainSingleFun(fr);
  H2O.submitTask(new LocalMR(fun, 100)).join();
 } finally {
  Scope.exit();
 }
}

代码示例来源:origin: h2oai/h2o-3

@BeforeClass
public static void setup() {
 stall_till_cloudsize(1);
 _covtype = parse_test_file("smalldata/covtype/covtype.20k.data");
 _covtype.replace(_covtype.numCols()-1,_covtype.lastVec().toCategoricalVec()).remove();
 Key[] keys = new Key[]{Key.make("train"),Key.make("test")};
 H2O.submitTask(new FrameSplitter(_covtype, new double[]{.8},keys,null)).join();
 _train = DKV.getGet(keys[0]);
 _test = DKV.getGet(keys[1]);
}

相关文章