Tensorboard安装与使用

Tensorboard安装(pip安装)

  • Anaconda Prompt安装tensorboard
    • tensorboard使用

Anaconda Prompt安装tensorboard

(base) C:\Users\小黄鸭>activate python3.6
(python3.6) C:\Users\小黄鸭>pip install tensorboard --target=D:\Tool\Anaconda\envs\python3.6\Lib\site-packages

pip安装**–target指定对应Anaconda的python环境目录**

tensorboard使用

import torchvision
from torch.utils.tensorboard import SummaryWriter
#设置数据集转换张量
dataset_transform = torchvision.transforms.Compose([torchvision.transforms.ToTensor()])
#获取测试数据集
test_set = torchvision.datasets.CIFAR10(root='./dataset', train=False, transform=dataset_transform, download=True)
#指定输出目录
writer = SummaryWriter("logs")
#输出10张图片
for i in range(10):
    img,target = test_set[i]
    writer.add_image('test_set',img,global_step=i)
writer.close()

点击运行,即可。

在 Anaconda环境下启动tensorboard(Pycharm的Terminal终端切换到anaconda参考

(python3.6) D:\Tool\Anaconda\Scripts>tensorboard --logdir=D:\Space\PythonSpace\torchvision-01\logs
TensorFlow installation not found - running with reduced feature set.
Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all
TensorBoard 2.9.1 at http://localhost:6006/ (Press CTRL+C to quit)

Tensorboard安装与使用_第1张图片

你可能感兴趣的:(python,开发语言)