lingvo.core.cluster_factory module

Cluster factory.

lingvo.core.cluster_factory.SetCluster(cls)[source]

Sets Cluster implementation.

lingvo.core.cluster_factory.Current()[source]

Returns the current cluster specification.

E.g.:

with Cluster(cluster_params) as foo:
  model = p.Instantiate()
  model.FProp()  # FProp can access foo through cluster_factory.Current().
lingvo.core.cluster_factory.ForTestingWorker(mode=None, job=None, gpus=None, split_size=None, tpus=None, add_summary=None, cpus=None, do_eval=None, num_tpu_hosts=None)[source]

Returns a Cluster for unittesting with a worker.

lingvo.core.cluster_factory.SetEval(mode)[source]

Returns a cluster with do_eval option turned on/off.

E.g.:

def FProp(...):
  with SetEval(mode=True):
    # Turns off dropout, noise, etc.
    y = self.foo.FProp(..., x)
    z = self.bar.FProp(..., y)
  # Returns to previous state (e.g., training).
  y = self.foo.FProp(..., x)
  z = self.foo.FProp(..., y)
Parameters

mode – True, False or None.

Returns

A new Cluster instance.

lingvo.core.cluster_factory.SetRequireSequentialInputOrder(mode)[source]

Returns a cluster with require_sequential_input_order option set.

Parameters

mode – True, False or None.

Returns

A new Cluster instance.

lingvo.core.cluster_factory.SetModelSplit(split_id)[source]

Returns the current cluster with the model split id set.

E.g.:

def FProp(...):
  with cluster_factory.SetModelSplit(1) as c:
    with tf.device(c.WorkerDeviceInModelSplit(0)):
      ...
Parameters

split_id – Integer split id for the model.

Returns

A new Cluster instance.