google-colaboratory - 在 Tensorflow 2.0 中,如何使用 Google Colab TPU 将检查点保存到 Google Cloud Storage?
问题描述
- Tensorflow 1.X 中的脚本,但在Tensorflow 2.0中仍然无法正常工作
2.如何将此 scipts 迁移到Tensorflow 2.0
import datetime
import json
import os
import pprint
import random
import string
import sys
import tensorflow as tf
import tensorflow_io as tfio
assert 'COLAB_TPU_ADDR' in os.environ, 'ERROR: Not connected to a TPU runtime; please see the first cell in this notebook for instructions!'
TPU_ADDRESS = 'grpc://' + os.environ['COLAB_TPU_ADDR']
print('TPU address is', TPU_ADDRESS)
from google.colab import auth
auth.authenticate_user()
with tf.compat.v1.Session(TPU_ADDRESS) as session:
print('TPU devices:')
pprint.pprint(session.list_devices())
# Upload credentials to TPU.
with open('/content/adc.json', 'r') as f:
auth_info = json.load(f)
tf.contrib.cloud.configure_gcs(session, credentials=auth_info)
# Now credentials are set for all future sessions on this TPU.
解决方案
推荐阅读
- reactjs - webpack 的 animate.css 导入失败
- java - java.text.ParseException:无法解析的日期:“23 de marzo de 2021”
- amazon-web-services - AWS Lambda 函数处理程序错误说没有足够的值来解压
- google-apps-script - 根据特定列值过滤工作表
- progressive-web-apps - 是否可以在 PWA 应用程序中处理滑动手势?
- sql - 嗨,我想计算一条记录出现的次数
- sql-server - 根据 DataView 的结果动态构建 SQL Insert 语句
- sql-server - 与我的组织共享 SSRS 报告
- ios - 如何检测重新选择事件并在颤动中导航到cupetinotab中的第一页
- javascript - 赛普拉斯:检测是否被点击