graph - Torch Tensorboard 图不反映代码
问题描述
我构建了一个由 VGG + 线性层的简单组合组成的视频编码器
vgg16 = tv.models.vgg16(pretrained=True)
vgg16.classifier = torch.nn.Sequential(*[l for l in vgg16.classifier[:5]])
for l in vgg16.features:
for p in l.parameters():
p.requires_grad = False
for l in vgg16.classifier[:-2]:
for p in l.parameters():
p.requires_grad = False
class Encoder(torch.nn.Module):
def __init__(self, emb_dimension):
super(Encoder, self).__init__()
self.vgg16 = vgg16
self.encoder = torch.nn.Sequential(
torch.nn.Linear(4096, emb_dimension),
# torch.nn.ReLU()
)
def forward(self, x):
batch_size, time_steps, *dims = x.shape
x = x.view(batch_size * time_steps, *dims)
x = vgg16(x)
x = x.view(batch_size, time_steps, -1)
x = self.encoder(x)
return x
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
encoder = Encoder(30)
encoder.to(device)
writer.add_graph(encoder, torch.rand(1,5,3,100,100).to(device))
我不明白为什么 tensorBoard 图显示 20 个从顺序层返回到 VGG 的张量。恐怕它可能会影响梯度计算。 有人有什么想法吗?
解决方案
推荐阅读
- arrays - 有没有办法将 postgres 数组映射到列表而不创建额外的表?
- angular - 使用表单获取用户输入并将该数据共享到不同的组件中以显示它
- node.js - 在 node.js 8.10 中使用异步瀑布的 AWS Lambda 查询
- java - 二进制/限定名称错误?开始于:
$ - vue.js - 在创建的函数中调用元素的 onscroll 事件
- html - HTML:检测 Unicode 并应用类
- python-3.x - 如何使用 pytesseract 从图像中获取文本?
- wpf - WPF ComboBox,设置当前项的背景颜色
- angular - Angular Element 中的独立路由器插座
- android - Lottie 动画 Drawable 在 Android 5 上的浮动操作按钮内渲染不正确