加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tenSorboard1.py 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
66666 提交于 2022-06-02 04:20 . Initial commit
# The following switch allows the program runs locally and in the Agit environment without modifications.
import os
path = os.path.dirname(__file__)
print(path)
if 'CLOUD_PROVIDER' in os.environ and os.environ['CLOUD_PROVIDER'] == 'Agit':
logdir = '/root/.agit'
else:
logdir = './runs'
# setup tensorboard path
import tensorflow as tf
writer = tf.summary.create_file_writer(logdir)
''' alternative tensorboards
# pytorch tensorboard :
from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter(log_dir=logdir)
# tensorboardX :
from tensorboardX import SummaryWriter
writer = SummaryWriter(logdir=logdir)
'''
import numpy as np
import time
# a 5 minutes running example, the realtime tensorboard can be viewed in the training page
with writer.as_default():
for n_iter in range(360):
tf.summary.scalar('Loss/train', np.random.random(), n_iter)
tf.summary.scalar('Loss/test', np.random.random(), n_iter)
tf.summary.scalar('Accuracy/train', np.random.random(), n_iter)
tf.summary.scalar('Accuracy/test', np.random.random(), n_iter)
time.sleep(1)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化