如何使用kaggle免费30个小时的TPU

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

1.说明

觊觎kaggle上TPU已久,今天正好试一下。。。

2.使用步骤

  1. 比赛官网
    在这里插入图片描述
  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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值