tf.contrib.tpu.keras_to_tpu_model
Копирует model вместе с весами на TPU. (устарело)
tf.contrib.tpu.keras_to_tpu_model(
model, strategy=None
)
Возвращает модель TPU.
Использование:
a = Input(shape=(32,))
b = Dense(32)(a)
model = Model(inputs=a, outputs=b)
# If `num_cores_per_host` is greater than one, batch parallelism will be used
# to run on multiple TPU cores.
strategy = keras_support.TPUDistributionStrategy(tpu_cluster_resolver)
model = keras_support.tpu_model(model, strategy)
model.compile(
optimizer=tf.compat.v1.train.GradientDescentOptimizer(learning_rate=1.0),
...)
| Аргументы | |
|---|---|
model | Экземпляр tf.keras.Model. |
strategy | TPUDistributionStrategy. Стратегия для репликации модели на нескольких ядрах TPU. |
| Возвращаемое значение | |
|---|---|
Новый экземпляр KerasTPUModel. |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/tpu/keras_to_tpu_model