您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这期内容当中小编将会给大家带来有关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了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。