Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于语义模块 #20

Closed
dong-0412 opened this issue Aug 27, 2022 · 1 comment
Closed

关于语义模块 #20

dong-0412 opened this issue Aug 27, 2022 · 1 comment

Comments

@dong-0412
Copy link

感谢你的回复,
我又回过头看了关于token semantic module 部分的代码,仍然有一些不明白的地方要请教你,

        B, N, C = x.shape
        SF = frames_num // (2 ** (len(self.depths) - 1)) // self.patch_stride[0]
        ST = frames_num // (2 ** (len(self.depths) - 1)) // self.patch_stride[1]
        x = x.permute(0,2,1).contiguous().reshape(B, C, SF, ST)        
        B, C, F, T = x.shape

        # group 2D CNN
        c_freq_bin = F // self.freq_ratio
        x = x.reshape(B, C, F // c_freq_bin, c_freq_bin, T)
        x = x.permute(0,1,3,2,4).contiguous().reshape(B, C, c_freq_bin, -1)

        x = self.tscam_conv(x)
        x = torch.flatten(x, 2) # B, C, T

1.group 2D 那里,前面已经将特征图分成了SF,ST 的形式了,这里的关于特征图的形状的变换的作用是什么?

2.self.tscam_conv处理后的特征图的形状变成了B,Class,T',那么这个T'是有什么物理意义在里面吗?

3.上述操作完成了我看到程序中对x进行上采样来生成fpx作为framewise_output,并用它来做定位(确定开始结束时间?),那么这个fpx为什么来用来做定位,以及fpx(B,1024,527)的1024的物理意义是什么?

希望您能抽空解决我的疑惑

Originally posted by @dong-0412 in #19 (comment)

@dong-0412 dong-0412 changed the title 关于语义模块的疑惑 关于语义模块 Aug 27, 2022
@RetroCirce
Copy link
Owner

  1. 这里的变换是将这个2D的特征图变成我们想要的顺序,你可以跟着这个reshape和permute想象一下:一个音频的T和F经过这个顺序是怎么变换的,这样的变换是符合我在文章中写到的time-frequency-window顺序,这个顺序被送入tscam_conv才能保证该cnn在时间轴和频域轴上处理是是符合我们预想的顺序
  2. 有的,从理论上讲,这个B,C,T就是一个事件随着时间变化的presence map,在T轴上,你可以得到每个时间(在某个分辨率下)帧上的事件都有哪些,这也是我们用来进行文章最后一个实验(DESED数据集)的最初结果来源。
  3. 根据2的结果,我们有一个BCT的map,但是这个T是包含一定分辨率的,它并不是1024的长度(原来的输入是1024),因此,我们需要将该T长度给拉伸到1024,假设T是64,那么我们是将它拉伸16倍,相当于T中的每一帧实际上是16帧,我们假设这16帧内他的事件就是固定的(其实你算一下就相当于是0.16秒,这个精度其实已经不错了),这里的1024就是对应原来10秒的时间,一帧是0.01秒;当然,这些其实都是可以根据你的训练和infer需求改变
  4. 至于为什么这个fpx可以用来定位,这其实是我们的一个设想,在以前基于cnn的模型中,最后几层的feature其实也是一个类似于BCT的格式,虽然我们只有弱标签答案,但是我们希望这最后一层的BCT可以代表类似于每个时间点上的事件信息,因为这个map是由模型在时间上滑动得到的结果,它确实是捕捉到了每个时间点上的事件信息。在我们的transformer模型中,我们也是这样设想的,因为transformer捕捉了每个时间点上的信息,将它变成了BCT的map。虽然我们只有弱标签答案,但是我们希望这最后一层的BCT可以代表类似于每个时间点上的事件信息

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants