首先要安装
pip install tensorboard
运行命令为 tensorboard --logdir=日志文件的绝对地址 --port=8008 端口号随意
如果运行上述命令出现以下问题
TensorFlow installation not found - running with reduced feature set.
说明TensorFlow 没有安装
pip install tensorflow
可视化模型结构
model = SwinUNETR( img_size=(args.roi_x, args.roi_y, args.roi_z), in_channels=args.in_channels, out_channels=args.out_channels, feature_size=args.feature_size, use_checkpoint=args.use_checkpoint, ) # print(model) input = torch.rand((1, 4, 128, 128, 128)) 这里是模型的输入 writer = SummaryWriter("保存的路径") writer.add_graph(model, input_to_model=torch.rand(1, 4, 128, 128, 128)) writer.close()
上面定义模型,
tensorboard --logdir=保存的路径 --port=8008