代码里一些不理解的问题
我认为这是一个非常优秀的工作,但是模型内部有些我不理解的问题,比如:
window_size = 1 # Window size for Gaussian position adjustments
pred = [] # List to store predictions
bs, _, _, _ = feat.shape # Batch size and feature dimensions
# Process features for color prediction
para_c = self.feat.reshape(bs, -1, lr_h * lr_w * 4).permute(1, 0, 2)
color = self.mlp(para_c.reshape(-1, bs * lr_h * lr_w * 4).permute(1, 0))
color = color.reshape(bs, lr_h * lr_w * 4, -1)
# Process features for Gaussian convariance parameter estimation
para_c = self.leaky_relu(self.feat)
para = self.conv1(para_c)
vector = self.mlp_vector(self.gau_dict.to(para.device)) # Transform Gaussian covariance dictionary to increase dimensions
para = para.reshape(bs, -1, lr_h * lr_w * 4).permute(1, 0, 2).reshape(-1, bs * lr_h * lr_w * 4)
para = vector @ para # This calculates the similarity between para and each element in the dictionary
para = torch.softmax(para, dim=0) # Normalize the similarity scores to produce weights using softmax
para = para.permute(1, 0) @ self.gau_dict.to(para.device) # Compute the weighted sum of dictionary elements to get the final covariance
para = para.reshape(bs, lr_h * lr_w * 4, -1)
# Process features for offset prediction
offset = self.mlp_offset(para_c.reshape(-1, bs * lr_h * lr_w * 4).permute(1, 0))
offset = torch.tanh(offset).reshape(bs, lr_h * lr_w * 4, -1)
此处不仅将h和w进行了展开,同时将batchsize维度也进行了展开并送入MLP中进行运算,在作者给出的测试配置中,batchsize被设置为1,所以或许没有问题,但是如果在训练过程中设置了不同batchsize或许会出现报错(?)所以我想询问一下这里将batchsize维度进行展开是否有实际意义
感谢对我们工作的关注!
在训练过程中可以设置不同的batchsize,不会出现报错。这里我们将batch维度一起展开,这是为了符合MLP输入的需要。再经过MLP后,我们又将张量调整回了含有batch的形状,例如https://github.com/peylnog/ContinuousSR/blob/main/models/gaussian.py#L222 这里将color的维度调整为(bs, lr_h * lr_w * 4, 3)。
感谢对我们工作的关注!
在训练过程中可以设置不同的batchsize,不会出现报错。这里我们将batch维度一起展开,这是为了符合MLP输入的需要。再经过MLP后,我们又将张量调整回了含有batch的形状,例如https://github.com/peylnog/ContinuousSR/blob/main/models/gaussian.py#L222 这里将color的维度调整为(bs, lr_h * lr_w * 4, 3)。
感谢回复,因为之前进行的cv工作,常用的设置一般不会展开batchsize维度,导致我忽略的线性层内部会自动将batchsize展开的问题,今天重新了解了一下线性层的输入格式,确实(B, N, C)和(B*N, C)都可以
不客气, 欢迎多多关注和 随时提问 , 我们会第一时间解答
不客气, 欢迎多多关注和 随时提问 , 我们会第一时间解答
还有一点就是,代码这里对协方差参数进行的调整,是有什么理论依据还是经验性的操作呢
# Adjust Gaussian parameters
weighted_cholesky = para_ / 4
weighted_opacity = torch.ones(color_.shape[0], 1).cuda()
weighted_cholesky[:, 0] *= scale2
weighted_cholesky[:, 1] *= scale2
weighted_cholesky[:, 2] *= scale1
这是一个经验性的操作。为了实现高质量的超分,我们为每个LR的像素点分配了四个高斯场,所以需要缩小每个高斯场的影响范围(协方差)来正确地拟合出连续信号。