Pytorch中如何使用tensorboard
这期内容当中小编将会给大家带来有关Pytorch中如何使用tensorboard,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
创新互联公司网站建设服务商,为中小企业提供成都网站建设、网站制作服务,网站设计,绵阳服务器托管等一站式综合服务型公司,专业打造企业形象网站,让您在众多竞争对手中脱颖而出创新互联公司。
安装:pip install tensorboard
或者安装tensorflow,默认CPU版本即可:pip install tensorflow
运行:tensorboard --logdir=runs
实验代码:
import torchimport torchvisionfrom torch.utils.tensorboard import SummaryWriterfrom torchvision import datasets, transforms# Writer will output to ./runs/ directory by defaultwriter = SummaryWriter()transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,))])trainset = datasets.MNIST('mnist_train', train=True, download=True, transform=transform)trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)model = torchvision.models.resnet50(False)# Have ResNet model take in grayscale rather than RGBmodel.conv1 = torch.nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False)images, labels = next(iter(trainloader))grid = torchvision.utils.make_grid(images)writer.add_image('images', grid, 0)writer.add_graph(model, images)writer.close()''' tensorboard --logdir=runs '''
运行完成之后在命令行下输入:tensorboard --logdir=runs
根据提示,打开链接: http://localhost:6006/
命令行下的输出是:
(base) PS C:\Users\chenxuqi\Desktop\News4cxq\tensorboard4cxq> conda activate pytorch_1.7.1_cu102 (pytorch_1.7.1_cu102) PS C:\Users\chenxuqi\Desktop\News4cxq\tensorboard4cxq> tensorboard --logdir=runs 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.4.0 at http://localhost:6006/ (Press CTRL+C to quit)
浏览器下显示效果展示:
上述就是小编为大家分享的Pytorch中如何使用tensorboard了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。
新闻标题:Pytorch中如何使用tensorboard
文章路径:http://cdiso.cn/article/pegges.html