【发布时间】:2021-03-26 04:44:47
【问题描述】:
由于我有一个大型数据集并且我的 PC 中没有太多功能,我认为在 Google Colab 上使用 TPU 是一个好主意。
所以,这是我的 TPU 配置:
try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver()
print('Running on TPU ', tpu.master())
except ValueError:
tpu = None
if tpu:
tf.config.experimental_connect_to_cluster(tpu)
tf.tpu.experimental.initialize_tpu_system(tpu)
strategy = tf.distribute.experimental.TPUStrategy(tpu)
else:
strategy = tf.distribute.get_strategy()
print("REPLICAS: ", strategy.num_replicas_in_sync)
这是我的训练:
hist = model.fit(train_dataset, epochs=10, verbose=1, steps_per_epoch=count_data_items(filenames)//64)
【问题讨论】:
标签: tensorflow machine-learning google-colaboratory tpu google-cloud-tpu