1.说明
觊觎kaggle上TPU已久,今天正好试一下。。。
2.使用步骤
- 比赛官网

- notebook使用教程

然后下个页面直接点create


3.TPU花卉识别
官网示例-A Simple TF 2.2 notebook
导入包:
import tensorflow as tf
from kaggle_datasets import KaggleDatasets
import numpy as np
print("Tensorflow version " + tf.__version__)
Tensorflow version 2.2.0
检测TPU:
# Detect hardware, return appropriate distribution strategy
try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver() # TPU detection. No parameters necessary if TPU_NAME environment variable is set. On Kaggle this is always the case.
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() # default distribution strategy in Tensorflow. Works on CPU and single GPU.
print("REPLICAS: ", strategy.num_replicas_in_sync)
Running on TPU grpc://10.0.0.2:8470
REPLICAS: 8
#Get my data path
GCS_DS_PATH = KaggleDatasets().get_gcs_path()
设置参数:
#参数
IMAGE_SIZE = [192, 192] # at this size, a GPU will run out of memory. Use the TPU
EPOCHS = 100
BATCH_SIZE = 32 * strategy.num_replicas_in_sync
NUM_TRAINING_IMAGES = 12753
NUM

该博客围绕TPU花卉识别展开,介绍了使用步骤,包括比赛官网及notebook使用教程,还说明了在页面点create的操作。详细阐述了TPU花卉识别过程,如导入包、检测TPU等。此外,给出了FC Ensemble External Data (EffNet+DenseNet)相关的高分代码。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



