用法
dequeue(
    name:Optional[Text] = None
)參數
- 
name底層操作的名稱。
返回
- 
張量的嵌套結構,結構與feature_config相同
拋出
- 
RuntimeError如果在TPUStrategy下未創建對象或未構建對象時調用(通過手動調用 build 或調用 enqueue)。
獲取嵌入結果。
返回 tf.Tensor 對象的嵌套結構,將 feature_config 參數的結構與 TPUEmbedding 類匹配。張量的輸出形狀是 (*output_shape, dim) ,  dim 是對應的 TableConfig 的維度。對於output_shape,可以設置三個位置。
- FeatureConfig 在 init 函數中提供。
- Per_replica_output_shapes通過初始化tpu嵌入類後直接調用build方法。
- 從輸入特征的形狀自動檢測。這些地方的優先級是完全相同的順序。
strategy = tf.distribute.TPUStrategy(...)
with strategy.scope():
  embedding = tf.tpu.experimental.embedding.TPUEmbedding(...)
distributed_dataset = (
    strategy.distribute_datasets_from_function(
        dataset_fn=...,
        options=tf.distribute.InputOptions(
            experimental_fetch_to_device=False))
dataset_iterator = iter(distributed_dataset)
@tf.function
def training_step():
  def tpu_step(tpu_features):
    with tf.GradientTape() as tape:
      activations = embedding.dequeue()
      tape.watch(activations)
      loss = ... #  some computation involving activations
    embedding_gradients = tape.gradient(loss, activations)
    embedding.apply_gradients(embedding_gradients)
  embedding_features, tpu_features = next(dataset_iterator)
  embedding.enqueue(embedding_features, training=True)
  strategy.run(tpu_step, args=(tpu_features, ))
training_step()傳遞給 TPUEmbedding 對象的實例。
相關用法
- Python tf.tpu.experimental.embedding.TPUEmbedding.apply_gradients用法及代碼示例
- Python tf.tpu.experimental.embedding.TPUEmbedding.enqueue用法及代碼示例
- Python tf.tpu.experimental.embedding.TPUEmbedding用法及代碼示例
- Python tf.tpu.experimental.embedding.TableConfig用法及代碼示例
- Python tf.tpu.experimental.embedding.FeatureConfig用法及代碼示例
- Python tf.tpu.experimental.embedding.FTRL用法及代碼示例
- Python tf.tpu.experimental.embedding.SGD用法及代碼示例
- Python tf.tpu.experimental.embedding.Adam用法及代碼示例
- Python tf.tpu.experimental.embedding.Adagrad用法及代碼示例
- Python tf.tpu.experimental.embedding.serving_embedding_lookup用法及代碼示例
- Python tf.tpu.experimental.DeviceAssignment用法及代碼示例
- Python tf.types.experimental.GenericFunction.get_concrete_function用法及代碼示例
- Python tf.train.Coordinator.stop_on_exception用法及代碼示例
- Python tf.train.ExponentialMovingAverage用法及代碼示例
- Python tf.train.Checkpoint.restore用法及代碼示例
- Python tf.test.is_built_with_rocm用法及代碼示例
- Python tf.train.Checkpoint.read用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.tpu.experimental.embedding.TPUEmbedding.dequeue。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
